F
Filament7mo ago
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(); });
4 Replies
toeknee
toeknee7mo ago
Can you explain what the issue is
Polash
Polash7mo ago
actually, how will I save the data in the database like "the date will be the same but the member and the type tag will be different"
toeknee
toeknee7mo ago
It depends on your requirement. How you have it now, it'll save as an array of data into the table with the column: items It's sounding like you want a pivot which saves the type tag
Polash
Polash7mo ago
like : 12-2-2024 112 Productive and so on...
Want results from more Discord servers?
Add your server