wip
This commit is contained in:
1 parent
23cf804865
commit
4e77862aa7
14 files changed
+113
-49
No files matched your search
@@ -3,15 +3,22 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\PersonalNotification;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
@@ -26,13 +33,59 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche
|
||||
{
|
||||
return $table
|
||||
->query(PersonalNotification::query()->with('bookmaker')->where('user_id', auth()->user()->id))
|
||||
->description('Send a notification when favorit enters an alarm level.')
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->id),
|
||||
TextColumn::make('sport.name'),
|
||||
BookmakerIcon::make('bookmaker.icon')->label('Icon')->size('lg'),
|
||||
// TextColumn::make('sport.name'),
|
||||
BookmakerIcon::make('bookmaker.icon')
|
||||
->label('Bookmaker')->size('lg'),
|
||||
// IconColumn::make('sport.icon')
|
||||
// ->label('')
|
||||
// ->color(fn ($record) => $record->sport->color)
|
||||
// ->icon(fn ($record) => $record->sport->icon)
|
||||
// ->size(IconSize::ExtraLarge),
|
||||
TextColumn::make('alarm_level.name')
|
||||
->color(fn ($record) => $record->alarm_level->color)
|
||||
->weight(FontWeight::Black)
|
||||
->extraCellAttributes(['class' => 'alarm-level-style']),
|
||||
])
|
||||
->defaultSort('alarm_level_id', 'desc')
|
||||
->deferFilters(false)
|
||||
->deferFilters(false)
|
||||
->filters([
|
||||
SelectFilter::make('bookmaker_id')
|
||||
->label('Bookmaker')
|
||||
->visible(fn () => auth()->user()->partner_bookmaker_id)
|
||||
->default(auth()->user()->bookmaker->id)
|
||||
->selectablePlaceholder(false)
|
||||
->options(Bookmaker::options([auth()->user()->partner_bookmaker_id, auth()->user()->bookmaker_id]))
|
||||
->preload(),
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->options(Sport::getSportForClient(auth()->user()->client_id))
|
||||
->preload(),
|
||||
], FiltersLayout::AboveContent)
|
||||
->filtersFormColumns(3)
|
||||
->hiddenFilterIndicators()
|
||||
->recordActions([
|
||||
Action::make('notify_by_system')
|
||||
->button()
|
||||
->label('Send Notification')
|
||||
->color(fn ($record) => $record->notify_by_system ? 'primary' : 'gray')
|
||||
->icon('phosphor-bell-duotone')
|
||||
->action(function ($record) {
|
||||
PersonalNotification::where('id', $record->id)->update(['notify_by_system' => ! $record->notify_by_system]);
|
||||
}),
|
||||
Action::make('notify_by_email')
|
||||
->label('Send E-Mail')
|
||||
->button()
|
||||
->color(fn ($record) => $record->notify_by_email ? 'primary' : 'gray')
|
||||
->icon('phosphor-envelope-duotone')
|
||||
->action(function ($record) {
|
||||
PersonalNotification::where('id', $record->id)->update(['notify_by_email' => ! $record->notify_by_email]);
|
||||
}),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user