Issue with Repeater in filamentphp

83 Views Asked by At

Trying to make a form with the repeater where I can pick a date and add multiple members with a type tag. 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" 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();
    });
0

There are 0 best solutions below