133 lines
3.8 KiB
PHP
133 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Clusters\Settings\CardStates;
|
|
|
|
use AbdulmajeedJamaan\FilamentTranslatableTabs\TranslatableTabs;
|
|
use App\Filament\Clusters\Settings\CardStates\Pages\ManageCardStates;
|
|
use App\Filament\Clusters\Settings\SettingsCluster;
|
|
use App\Modules\CardOrder\Models\CardState;
|
|
use BackedEnum;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class CardStateResource extends Resource
|
|
{
|
|
protected static ?string $model = CardState::class;
|
|
|
|
protected static ?string $cluster = SettingsCluster::class;
|
|
|
|
protected static ?int $navigationSort = 2;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClipboardDocumentList;
|
|
|
|
protected static ?string $recordTitleAttribute = 'name';
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('Cards');
|
|
}
|
|
|
|
public static function getModelLabel(): string
|
|
{
|
|
return __('Card state');
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return __('Card states');
|
|
}
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->columns(2)
|
|
->components([
|
|
TranslatableTabs::make('nam')
|
|
->schema([
|
|
TextInput::make('name')
|
|
->label(__('Card state'))
|
|
->columnSpan(1)
|
|
->required(),
|
|
]),
|
|
|
|
Section::make(__('General'))
|
|
->columns(6)
|
|
->schema([
|
|
TextInput::make('price')
|
|
->label(__('Price'))
|
|
->columnSpan(4)
|
|
->required(),
|
|
|
|
Toggle::make('active')
|
|
->label(__('Active'))
|
|
->default(true)
|
|
->inline(false)
|
|
->columnSpan(2)
|
|
->required(),
|
|
|
|
TextInput::make('notes')
|
|
->label(__('Notes'))
|
|
->columnSpanFull()
|
|
->default(null),
|
|
]),
|
|
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->searchable(),
|
|
|
|
TextColumn::make('price')
|
|
->searchable(),
|
|
|
|
TextColumn::make('notes'),
|
|
|
|
IconColumn::make('active')
|
|
->boolean(),
|
|
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageCardStates::route('/'),
|
|
];
|
|
}
|
|
}
|