init
This commit is contained in:
11
app/Filament/Resources/Tiers/Pages/CreateTier.php
Normal file
11
app/Filament/Resources/Tiers/Pages/CreateTier.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Tiers\Pages;
|
||||
|
||||
use App\Filament\Resources\Tiers\TierResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTier extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TierResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Tiers/Pages/EditTier.php
Normal file
19
app/Filament/Resources/Tiers/Pages/EditTier.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Tiers\Pages;
|
||||
|
||||
use App\Filament\Resources\Tiers\TierResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTier extends EditRecord
|
||||
{
|
||||
protected static string $resource = TierResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Tiers/Pages/ListTiers.php
Normal file
19
app/Filament/Resources/Tiers/Pages/ListTiers.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Tiers\Pages;
|
||||
|
||||
use App\Filament\Resources\Tiers\TierResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTiers extends ListRecords
|
||||
{
|
||||
protected static string $resource = TierResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Filament/Resources/Tiers/Schemas/TierForm.php
Normal file
36
app/Filament/Resources/Tiers/Schemas/TierForm.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Tiers\Schemas;
|
||||
|
||||
use App\DataSourceFields;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TierForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('slug')
|
||||
->required(),
|
||||
Textarea::make('description')
|
||||
->columnSpanFull(),
|
||||
CheckboxList::make('allowed_fields')
|
||||
->label('Allowed Fields')
|
||||
->options(array_combine(
|
||||
DataSourceFields::DVLA,
|
||||
DataSourceFields::DVLA
|
||||
))
|
||||
->columns(3)
|
||||
->searchable()
|
||||
->bulkToggleable()
|
||||
->helperText('Select which fields this tier can access.')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
52
app/Filament/Resources/Tiers/Tables/TiersTable.php
Normal file
52
app/Filament/Resources/Tiers/Tables/TiersTable.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Tiers\Tables;
|
||||
|
||||
use App\DataSourceFields;
|
||||
use App\Models\Tier;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TiersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('slug')
|
||||
->searchable(),
|
||||
TextColumn::make('allowed_fields')
|
||||
->label('Fields')
|
||||
->state(function (Tier $record): string {
|
||||
$total = count(DataSourceFields::DVLA);
|
||||
$selected = count($record->allowed_fields ?? []);
|
||||
|
||||
return "{$selected} of {$total}";
|
||||
}),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
48
app/Filament/Resources/Tiers/TierResource.php
Normal file
48
app/Filament/Resources/Tiers/TierResource.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Tiers;
|
||||
|
||||
use App\Filament\Resources\Tiers\Pages\CreateTier;
|
||||
use App\Filament\Resources\Tiers\Pages\EditTier;
|
||||
use App\Filament\Resources\Tiers\Pages\ListTiers;
|
||||
use App\Filament\Resources\Tiers\Schemas\TierForm;
|
||||
use App\Filament\Resources\Tiers\Tables\TiersTable;
|
||||
use App\Models\Tier;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TierResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Tier::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TierForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TiersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTiers::route('/'),
|
||||
'create' => CreateTier::route('/create'),
|
||||
'edit' => EditTier::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user