add Custom Groups
This commit is contained in:
1 parent
c5118a4fd0
commit
6e7ebd7a9e
11 files changed
+216
-14
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Actions\LoadCountryGroups;
|
||||
use App\Models\ClientGroupList;
|
||||
use App\Models\CompetitionGroup;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ClientGroupListEditor extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(ClientGroupList::query())
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('client_groups')
|
||||
->label('Leagues')
|
||||
->badge()
|
||||
->wrap()
|
||||
->color('info')
|
||||
->formatStateUsing(fn (string $state): string => CompetitionGroup::where('id', $state)->pluck('name')->first()),
|
||||
])
|
||||
->filters([
|
||||
// ...
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make('edit')
|
||||
->iconButton()
|
||||
->mutateDataUsing(function (array $data): array {
|
||||
$data['client_id'] = auth()->user()->client_id;
|
||||
$data['sport_id'] = auth()->user()->sport_id;
|
||||
|
||||
return $data;
|
||||
})
|
||||
->schema([
|
||||
TextInput::make(name: 'name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Select::make('client_groups')
|
||||
->searchable()
|
||||
->multiple()
|
||||
->preload()
|
||||
->options(fn () => LoadCountryGroups::load()),
|
||||
])->action(function ($livewire) {
|
||||
$livewire->dispatch('refreshBettypeMenu');
|
||||
}),
|
||||
DeleteAction::make('delete')->iconButton(),
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->label('New Group')
|
||||
->schema([
|
||||
TextInput::make(name: 'name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Select::make('client_groups')
|
||||
->searchable()
|
||||
->options(fn () => LoadCountryGroups::load()),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.client-group-list-editor');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user