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) {
),
Solution:Jump to solution
```php
->createOptionUsing(function(array $data) {
dd($data);
// Create manually your new row in your pivot model and access to $model
$model = Model::create($data);...
2 Replies