can't assign role to customer

i was trying to assign when customer is created i created a user for the customer in aftercreate method then assign customer role but am getting this error and here is my code resource
->schema([
                Forms\Components\DatePicker::make('date')
                    ->firstDayOfWeek(6)
                    ->maxDate(now())
                    ->closeOnDateSelection()
                    ->default(Carbon::now())
                    ->native(false)->required(),
                Forms\Components\Radio::make('type')
                    ->options([
                        'individual' => 'Individual',
                        'business' => 'Business',
                    ])->required()->default('individual')->columns(4),
                Forms\Components\TextInput::make('name')->required(),
                Forms\Components\TextInput::make('mobile')->required()->unique(ignoreRecord: true),
                Forms\Components\TextInput::make('email')->required()->email()->unique(ignoreRecord: true),

                Forms\Components\Radio::make('access')
                    ->required()
                    ->label('Portal Access')
                    ->live()
                    ->options([
                        true => 'Allow',
                        false => 'Not Allow',
                    ])->default(false)->columns(4),

                Forms\Components\Select::make('roles')
                    ->live()
                    ->hidden(fn(\Filament\Forms\Get $get) => $get('access') == false)
                    ->required(function (\Filament\Forms\Get $get) {
                        return $get('access') == true;
                    })
                    ->relationship('roles', 'name')
                    ->multiple()
                    ->preload()
                    ->searchable(),

            ]);

i think the relationship is causing the error any idea plz
image.png
Was this page helpful?