wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\PersonalNotification;
|
||||
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\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;
|
||||
|
||||
class PersonalNotificationTable extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(PersonalNotification::query()
|
||||
->with('bookmaker')
|
||||
->where('alarm_level_id', '>', 1)
|
||||
->where('user_id', auth()->user()->id))
|
||||
->description('Send a notification when favorit enters an alarm level.')
|
||||
->striped()
|
||||
->columns([
|
||||
TextColumn::make('alarm_level.name')
|
||||
->color(fn ($record) => $record->alarm_level->color)
|
||||
->weight(FontWeight::Black),
|
||||
BookmakerIcon::make('bookmaker.icon')
|
||||
->alignCenter()
|
||||
->label('Bookmaker')->size('sm'),
|
||||
])
|
||||
->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(),
|
||||
], 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]);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.personal-notification-table');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user