Initial commit
This commit is contained in:
11
app/Filament/Resources/Platforms/Pages/CreatePlatform.php
Normal file
11
app/Filament/Resources/Platforms/Pages/CreatePlatform.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Platforms\Pages;
|
||||
|
||||
use App\Filament\Resources\Platforms\PlatformResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePlatform extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PlatformResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Platforms/Pages/EditPlatform.php
Normal file
19
app/Filament/Resources/Platforms/Pages/EditPlatform.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Platforms\Pages;
|
||||
|
||||
use App\Filament\Resources\Platforms\PlatformResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPlatform extends EditRecord
|
||||
{
|
||||
protected static string $resource = PlatformResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Platforms/Pages/ListPlatforms.php
Normal file
19
app/Filament/Resources/Platforms/Pages/ListPlatforms.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Platforms\Pages;
|
||||
|
||||
use App\Filament\Resources\Platforms\PlatformResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPlatforms extends ListRecords
|
||||
{
|
||||
protected static string $resource = PlatformResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
50
app/Filament/Resources/Platforms/PlatformResource.php
Normal file
50
app/Filament/Resources/Platforms/PlatformResource.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Platforms;
|
||||
|
||||
use App\Filament\Resources\Platforms\Pages\CreatePlatform;
|
||||
use App\Filament\Resources\Platforms\Pages\EditPlatform;
|
||||
use App\Filament\Resources\Platforms\Pages\ListPlatforms;
|
||||
use App\Filament\Resources\Platforms\Schemas\PlatformForm;
|
||||
use App\Filament\Resources\Platforms\Tables\PlatformsTable;
|
||||
use App\Models\Platform;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PlatformResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Platform::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Cube;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PlatformForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return PlatformsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListPlatforms::route('/'),
|
||||
'create' => CreatePlatform::route('/create'),
|
||||
'edit' => EditPlatform::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Filament/Resources/Platforms/Schemas/PlatformForm.php
Normal file
26
app/Filament/Resources/Platforms/Schemas/PlatformForm.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Platforms\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class PlatformForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(100),
|
||||
TextInput::make('slug')
|
||||
->required()
|
||||
->unique( ignoreRecord: true )
|
||||
->maxLength(100),
|
||||
TextInput::make('short_name')
|
||||
->default(null)
|
||||
->maxLength(30),
|
||||
]);
|
||||
}
|
||||
}
|
||||
45
app/Filament/Resources/Platforms/Tables/PlatformsTable.php
Normal file
45
app/Filament/Resources/Platforms/Tables/PlatformsTable.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Platforms\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PlatformsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('slug')
|
||||
->searchable(),
|
||||
TextColumn::make('short_name')
|
||||
->searchable(),
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user