Polash
Issue with Repeater
Trying to make a form with the repeater where I can pick a date and add multiple members with a type tag. How can I achieve it?
#TIA
the form:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\DatePicker::make('start_date')->rules(['required'])->label('Week Start Date')->required(),
Repeater::make('items')
->schema([
Forms\Components\Select::make('member_id')
->relationship('member', 'name')
->searchable()
->preload()->rules(['required'])->label('Member Name')->required(),
Forms\Components\Select::make('type')
->options([
'Productive' => 'Productive',
'Effective' => 'Effective',
"CEO's Favorite" => "CEO's Favorite",
])->searchable()->label('Winning Type')
->required(),
]),
]);
}
and the migration table:
Schema::create('weekly_winners', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('member_id');
$table->foreign('member_id')->references('id')->on('members');
$table->date('start_date')->nullable();
$table->string('type')->nullable();
$table->timestamps();
});
6 replies