move all into clusters
This commit is contained in:
1 parent
7ff3fbadb6
commit
a980ea92ce
91 files changed
+300
-262
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\Pages\ListClients;
|
||||
use App\Filament\Clusters\User\Resources\Clients\Schemas\ClientForm;
|
||||
use App\Filament\Clusters\User\Resources\Clients\Tables\ClientsTable;
|
||||
use App\Filament\Clusters\User\UserCluster;
|
||||
use App\Models\Client;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ClientResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Client::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-baseball-helmet';
|
||||
|
||||
protected static ?string $cluster = UserCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'User';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ClientForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ClientsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListClients::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\ClientResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateClient extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\ClientResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditClient extends EditRecord
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\ClientResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListClients extends ListRecords
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Schemas;
|
||||
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ClientForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('homepage')
|
||||
->default(null),
|
||||
Select::make('bookmaker')
|
||||
->options(Bookmaker::query()->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
Select::make('provider')
|
||||
->options(Provider::query()->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
Select::make('sport')
|
||||
->options(Sport::query()->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Tables;
|
||||
|
||||
use App\Actions\SettingGeneratorClient;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ClientsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('bookmaker')
|
||||
->wrap()
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => Bookmaker::where('id', $state)->pluck('name')->first()),
|
||||
TextColumn::make('provider')
|
||||
->badge()
|
||||
->wrap()
|
||||
->color('success')
|
||||
->formatStateUsing(fn (string $state): string => Provider::where('id', $state)->pluck('name')->first()),
|
||||
TextColumn::make('sport')
|
||||
->badge()
|
||||
->wrap()
|
||||
->color('warning')
|
||||
->formatStateUsing(fn (string $state): string => Sport::where('id', $state)->pluck('name')->first()),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('Create Settings')
|
||||
->icon('phosphor-gear-fine')
|
||||
->tooltip('Generates basic configuration for client')
|
||||
->action(function ($record) {
|
||||
SettingGeneratorClient::run($record);
|
||||
}),
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user