Update pivot table when editing record
Hi there,
I am trying to update a pivot table record while editing the main record.
I have the following table
team_user
user_id
team_id
operator_id (just a string value I wish to update)
On both user and team I have belongsToMany (M:M relationship).
This is how I fetch the operator_id in the table, using the team_user pivot table
How can I acomplish the same so when the record is created, operator_id is filled from the form and when the record is being edited, operator ID gets displayed and can be edited?
I am trying to update a pivot table record while editing the main record.
I have the following table
team_user
user_id
team_id
operator_id (just a string value I wish to update)
On both user and team I have belongsToMany (M:M relationship).
This is how I fetch the operator_id in the table, using the team_user pivot table
TextColumn::make('operator_id')->label('Oznaka operatera')->sortable()->searchable()
->state(function (User $record): string {
return $record->getUserInTeam()->first()->pivot->operator_id;
}),How can I acomplish the same so when the record is created, operator_id is filled from the form and when the record is being edited, operator ID gets displayed and can be edited?