Schilly
Schilly
FFilament
Created by Schilly on 11/15/2024 in #❓┊help
Select Column Saving
Having an issue where on my production server (Forge) for 1 specific relationship management page, it will not save any fields... I have a resource setup as follows (attached) - and it does not work... Whereas another resource, with the same setup just a different relationship - it does not work. I am getting no error messages to speak of - and the payload in the console seems to be going through... But it is not saving.
2 replies
FFilament
Created by Schilly on 11/1/2024 in #❓┊help
Import Action - "unknown column '' in `where clause` "
Hello - I am trying to get this importer to behave... I am using it to import records into a Relationship Pivot Table. The relationship is a belongsToMany relationship - and knowing that it will not play nice on that end, I have made up a Pivot Model to interact with. Here is the pivot model:
<?php

namespace App\Models\S3Operations;

use App\Models\S3Operations\Operation;
use App\Models\S5Logistics\Warehouse;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;

class OperationWarehouse extends Pivot
{

protected $fillable =
[
'operation_id',
'warehouse_id',
'fuel',
'aircraft',
'equipment'
];

public function operation(): BelongsTo
{
return $this->belongsTo(Operation::class);
}

public function warehouse(): BelongsTo
{
return $this->belongsTo(Warehouse::class);
}
}
<?php

namespace App\Models\S3Operations;

use App\Models\S3Operations\Operation;
use App\Models\S5Logistics\Warehouse;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;

class OperationWarehouse extends Pivot
{

protected $fillable =
[
'operation_id',
'warehouse_id',
'fuel',
'aircraft',
'equipment'
];

public function operation(): BelongsTo
{
return $this->belongsTo(Operation::class);
}

public function warehouse(): BelongsTo
{
return $this->belongsTo(Warehouse::class);
}
}
To go along with the pivot model - I ahve made up the Importer, as follows:
<?php

namespace App\Filament\Imports;

use App\Models\S3Operations\OperationWarehouse;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class OperationWarehouseImporter extends Importer
{
protected static ?string $model = OperationWarehouse::class;

public static function getColumns(): array
{
return [
ImportColumn::make('operation_id')
->integer()
->requiredMapping(),
ImportColumn::make('warehouse_id')
->integer()
->requiredMapping(),
ImportColumn::make('fuel')
->numeric(decimalPlaces: 2)
->requiredMapping(),
ImportColumn::make('aircraft')
->requiredMapping(),
ImportColumn::make('equipment')
->requiredMapping(),
];
}

public function resolveRecord(): ?OperationWarehouse
{
$warehouseID = $this->data['warehouse_id'];

return OperationWarehouse::firstOrNew(["warehouse_id" => $warehouseID]);

// return new OperationWarehouse();
}

public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your equipment import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';

if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}

return $body;
}
}
<?php

namespace App\Filament\Imports;

use App\Models\S3Operations\OperationWarehouse;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class OperationWarehouseImporter extends Importer
{
protected static ?string $model = OperationWarehouse::class;

public static function getColumns(): array
{
return [
ImportColumn::make('operation_id')
->integer()
->requiredMapping(),
ImportColumn::make('warehouse_id')
->integer()
->requiredMapping(),
ImportColumn::make('fuel')
->numeric(decimalPlaces: 2)
->requiredMapping(),
ImportColumn::make('aircraft')
->requiredMapping(),
ImportColumn::make('equipment')
->requiredMapping(),
];
}

public function resolveRecord(): ?OperationWarehouse
{
$warehouseID = $this->data['warehouse_id'];

return OperationWarehouse::firstOrNew(["warehouse_id" => $warehouseID]);

// return new OperationWarehouse();
}

public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your equipment import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';

if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}

return $body;
}
}
The problem I am having is - the importer is throwing an error as follows:
[2024-11-01 15:33:37] local.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (Connection: mysql, SQL: update `operation_warehouse` set `fuel` = 750, `aircraft` = [{"airframe_id":"4","qty":"22"},{"airframe_id":"8","qty":"5"}], `equipment` = [{"equipment_id":"177","qty":"150"},{"equipment_id":"6","qty":"150"},{"equipment_id":"30","qty":"150"}], `operation_warehouse`.`updated_at` = 2024-11-01 15:33:37 where `` = 1 and `` = 1) {"userId":205358980568973312,"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (Connection: mysql, SQL: update `operation_warehouse` set `fuel` = 750, `aircraft` = [{\"airframe_id\":\"4\",\"qty\":\"22\"},{\"airframe_id\":\"8\",\"qty\":\"5\"}], `equipment` = [{\"equipment_id\":\"177\",\"qty\":\"150\"},{\"equipment_id\":\"6\",\"qty\":\"150\"},{\"equipment_id\":\"30\",\"qty\":\"150\"}], `operation_warehouse`.`updated_at` = 2024-11-01 15:33:37 where `` = 1 and `` = 1) at C:\\Users\\patri\\Herd\\hvy\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:825)
[2024-11-01 15:33:37] local.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (Connection: mysql, SQL: update `operation_warehouse` set `fuel` = 750, `aircraft` = [{"airframe_id":"4","qty":"22"},{"airframe_id":"8","qty":"5"}], `equipment` = [{"equipment_id":"177","qty":"150"},{"equipment_id":"6","qty":"150"},{"equipment_id":"30","qty":"150"}], `operation_warehouse`.`updated_at` = 2024-11-01 15:33:37 where `` = 1 and `` = 1) {"userId":205358980568973312,"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (Connection: mysql, SQL: update `operation_warehouse` set `fuel` = 750, `aircraft` = [{\"airframe_id\":\"4\",\"qty\":\"22\"},{\"airframe_id\":\"8\",\"qty\":\"5\"}], `equipment` = [{\"equipment_id\":\"177\",\"qty\":\"150\"},{\"equipment_id\":\"6\",\"qty\":\"150\"},{\"equipment_id\":\"30\",\"qty\":\"150\"}], `operation_warehouse`.`updated_at` = 2024-11-01 15:33:37 where `` = 1 and `` = 1) at C:\\Users\\patri\\Herd\\hvy\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:825)
But the "warehouse_id" is 100% being set in the firstOrNew method... Thoughts?
7 replies
FFilament
Created by Schilly on 9/25/2024 in #❓┊help
DateTimePicker 24-Hour Clock
Greetings - I am trying to utilize the date-time-picker but looking to use a 24hr clock rather than AM/PM - is there any functionality to change this? I cannot find anything in the docs anywhere to indicate this as being an option. Thanks!
2 replies
FFilament
Created by Schilly on 2/6/2024 in #❓┊help
Text Column Badge Color based on Pivot attribute
Hello, I am trying to define a badge color based on the value of a pivot attribute. For example: - User belongsToMany Squadrons and the Squadrons belongsToMany Users - both withPivot('is_primary'). I am hoping to change the badge color based on the Boolean is_primary - I cannot for the life of me figure out how to get it to dynamically change based on the pivot Boolean. Thoughts?
100 replies
FFilament
Created by Schilly on 1/25/2024 in #❓┊help
dynamic Use $class;
I am working on making a plugin / module / whatever you want to call it... I am curious to know if it is possible to dynamically call a model name based off a config value. EG: config value is: USER_MODEL = "\App\Model\User" and in the model class I want to be able to dynamically set that for the: Use $user_model; part at the top.. I am not sure if this is even possible or not?
12 replies