query(User::query()->where('client_id', auth()->user()->client_id)->orwhereIn('id', [1, 2])) ->description('Send a message to one of the user listed') ->columns([ TextColumn::make('name')->icon('phosphor-user-duotone')->searchable(), TextColumn::make('email')->icon('phosphor-envelope-duotone'), ]) ->recordActions([ Action::make('notification') ->icon('phosphor-note-pencil-duotone') ->tooltip('Create a notification') ->modalHeading(fn ($record) => 'Send a notification to '.$record->name) ->iconButton() ->modalWidth(Width::Large) // ->modalDescription('Send a notification') ->modalSubmitActionLabel('Send') ->modalIcon('phosphor-envelope-duotone') ->schema([ Textarea::make('message') ->required() ->rows(4), Toggle::make('notify_by_email')->label('Send also as email') // ->belowContent('Notify me also by e-mail') ->onColor('info') ->offColor('gray'), ])->action(function (array $data, $record) { if ($data['notify_by_email']) { Mail::to($record) ->send(new UserNotification($data['message'])); } Notification::make() ->title('Notification from '.$record->name) ->icon('phosphor-envelope-duotone') ->body($data['message']) ->sendToDatabase($record); Notification::make() ->title('Message send successfully') ->success() ->send(); }), ]); } public function render(): View { return view('livewire.user-notifications'); } }