F
Filament11mo ago
Jap

Select multiple inside Repeater saved in one model.

Repeater::make('employeeDesignations')
->schema([
Select::make('department_id')
->multiple()
->options(
User::all()->pluck('name', 'id')
)
->required(),
Select::make('term_id')
->options(
Term::all()->pluck('name', 'id')
)
->required(),
])
->columns(2)
Repeater::make('employeeDesignations')
->schema([
Select::make('department_id')
->multiple()
->options(
User::all()->pluck('name', 'id')
)
->required(),
Select::make('term_id')
->options(
Term::all()->pluck('name', 'id')
)
->required(),
])
->columns(2)
Model:
class Employee extends Model
{
public function employeeDesignations()
{
return $this->hasMany(EmployeeDesignation::class);
}
}
class EmployeeDesignation extends Model
{

protected $fillable = [
'employee_id',
'department_id',
'term_id',
];
}
class Employee extends Model
{
public function employeeDesignations()
{
return $this->hasMany(EmployeeDesignation::class);
}
}
class EmployeeDesignation extends Model
{

protected $fillable = [
'employee_id',
'department_id',
'term_id',
];
}
Anyone can help me implement this? Thanks. Im getting error department_id should be string instead of array. I'm trying to lessen the rows created in the repeater by just using select multiple if it will just have the same term_id.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server