121 lines
3.9 KiB
PHP
121 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\SignatureItems;
|
|
|
|
use App\Filament\Resources\SignatureItems\Pages\ManageSignatureItems;
|
|
use App\Models\SignatureItem;
|
|
use BackedEnum;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\ImageColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class SignatureItemResource extends Resource
|
|
{
|
|
protected static ?string $model = SignatureItem::class;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedStar;
|
|
|
|
protected static ?string $navigationLabel = 'Aýratynlyklar';
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Sahypa mazmunu';
|
|
|
|
protected static ?int $navigationSort = 2;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->label('Ady')
|
|
->required(),
|
|
TextInput::make('price')
|
|
->label('Bahasy')
|
|
->required()
|
|
->numeric()
|
|
->prefix('TMT'),
|
|
TextInput::make('price_unit')
|
|
->label('Baha birligi')
|
|
->required()
|
|
->default('kg'),
|
|
TextInput::make('sort_order')
|
|
->label('Tertip')
|
|
->required()
|
|
->numeric()
|
|
->default(0),
|
|
Toggle::make('is_active')
|
|
->label('Işjeň')
|
|
->default(true),
|
|
Textarea::make('description')
|
|
->label('Beýany')
|
|
->rows(3)
|
|
->columnSpanFull(),
|
|
FileUpload::make('image')
|
|
->label('Surat')
|
|
->image()
|
|
->disk('public')
|
|
->directory('signature-items')
|
|
->columnSpanFull(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
ImageColumn::make('image')
|
|
->label('Surat')
|
|
->square(),
|
|
TextColumn::make('name')
|
|
->label('Ady')
|
|
->searchable(),
|
|
TextColumn::make('price')
|
|
->label('Bahasy')
|
|
->formatStateUsing(fn ($state) => number_format($state, 2).' TMT / ')
|
|
->sortable(),
|
|
TextColumn::make('price_unit')
|
|
->label('Birlik'),
|
|
IconColumn::make('is_active')
|
|
->label('Işjeň')
|
|
->boolean(),
|
|
TextColumn::make('sort_order')
|
|
->label('Tertip')
|
|
->numeric()
|
|
->sortable(),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->defaultSort('sort_order')
|
|
->filters([])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageSignatureItems::route('/'),
|
|
];
|
|
}
|
|
}
|