jackoripo
jackoripo
FFilament
Created by mango1026 on 8/1/2023 in #❓┊help
Possible to use TextInputColumn to update a relationship that has pivot table?
Just as an addition I have added a notification to each TextInputColumn Tables\Columns\TextInputColumn::make('monday') ->rules(['required', 'numeric', 'between:0,24']) ->updateStateUsing(function (Model $record, $state) { // Get the old Monday hours and calculate the difference $oldHours = $record->monday; $difference = $oldHours - $state; // Update the 'monday' column and calculate the new contracted hours $record->monday = $state; $contractedDifference = $record->contracted_hours - $difference; // Update the 'contracted_hours' column $record->contracted_hours = $contractedDifference; $record->save(); Notification::make() ->title('Updated successfully') ->icon('heroicon-o-face-smile') ->iconColor('success') ->duration(3000) ->send(); // Return the updated model instance return $record; }),
9 replies
FFilament
Created by mango1026 on 8/1/2023 in #❓┊help
Possible to use TextInputColumn to update a relationship that has pivot table?
Thank you for pointing me in the direction of the updateStateUsing, i was able to update a column when i editted a column in the table. 👍
9 replies