AngryTestie
Check if the data has been change before saving
I'm trying to send a notification to the process owner everytime the data of process owner is change after saving. I don't want to spam notification everytime the user click the save so I want to check it before saving. The code below always returns false even if I'm changing the value of the process_owner
protected function beforeSave(): void
{
dd($this->record->isDirty('process_owner'));
}
4 replies
How to get the id of the data created using createOptionUsing()
I want to add a data in the pivot table after creating the data. Now I don't have the access on the id of the newly created data. How can I do this
Forms\Components\Select::make('process_owner')
->label('Process Owner')
->relationship('processowner','name', fn (Builder $query) => $query->whereHas('companies', fn ($query) => $query->where('company_id', Auth::user()->current_company_id)))
->preload()
->searchable()
->createOptionForm([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('email')
->required(),
Hidden::make('password')
->required()
->default(Hash::make('password'))
->disabled(),
Hidden::make('current_company_id')
->default( Auth::user()->current_company_id)
])
->createOptionUsing(function(array $data) {
),
5 replies
How to run a function after adding new data using createOptionForm()
I want to inser data in pivot table after new data is save.How can I do that?here is my code .
Forms\Components\Select::make('location')
->label('Location')
->multiple()
->relationship('locations','location_name',fn (Builder $query) => $query->where('company_id', Auth::user()->current_company_id))
->preload()
->createOptionForm([
Forms\Components\TextInput::make('location_name')
->required(),
Hidden::make('company_id')
->default( Auth::user()->current_company_id)
]),
6 replies