JL
JL
FFilament
Created by JL on 9/13/2023 in #❓┊help
Add value to field in pivot table in CreateAction
Yes, the code is in SubcategoriesRelationManager I get it: ->headerActions([ CreateAction::make() ->using(function (array $data, string $model): Model { $table = $this->getTable(); $relationship = $table->getRelationship(); $pivotData = []; $pivotColumns = $relationship->getPivotColumns(); $pivotData = Arr::only($data, $pivotColumns); $data = Arr::except($data, $pivotColumns); $parentCategory = $relationship->getParent(); $pivotData['pivotorder'] = $relationship->max('pivotorder') + 1; $record = new $model(); $record->fill($data); $relationship->save($record, $pivotData); return $record; }) ]) Now that I can debug it was easier 🙂 but surely there is a better way to do it than copy and paste 🙂 Very thanks
6 replies
FFilament
Created by JL on 9/13/2023 in #❓┊help
Add value to field in pivot table in CreateAction
Hello, yes, thanks if I remove the emptyStateActions, if enters in the using in headerActions
6 replies