This commit is contained in:
salam committed 2026-02-05 18:48:51 +01:00
1 parent b0a002c7c1
commit 23cf804865
23 files changed
+283 -123

No files matched your search

+20 -4
View File
@@ -3,6 +3,7 @@
namespace App\Livewire;
use App\Mail\UserNotification;
use App\Models\PersonalNotification;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
@@ -13,6 +14,7 @@ use Filament\Notifications\Notification;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\Width;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
@@ -27,6 +29,8 @@ class UserNotifications extends Component implements HasActions, HasSchemas, Has
use InteractsWithSchemas;
use InteractsWithTable;
protected Table $table2;
public function table(Table $table): Table
{
return $table
@@ -48,12 +52,14 @@ class UserNotifications extends Component implements HasActions, HasSchemas, Has
->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']));
@@ -69,13 +75,23 @@ class UserNotifications extends Component implements HasActions, HasSchemas, Has
->success()
->send();
}),
])
->toolbarActions([
// ...
]);
}
public function table2(Table $table): Table
{
return $table
->query(PersonalNotification::query()->where('user_id', auth()->user()->id))
->columns([
IconColumn::make('sport.icon')
->label('')
->icon(fn ($record) => $record->sport->icon)
->tooltip(fn ($record) => $record->id)
->visibleFrom('lg'),
]);
}
public function render(): View
{
return view('livewire.user-notifications');