You've already forked Atomcms-edit
112 lines
2.8 KiB
PHP
Executable File
112 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Filament\Resources\Shop;
|
|
|
|
use App\Filament\Resources\Shop\ShopOrderResource\Pages\ListShopOrders;
|
|
use App\Filament\Traits\TranslatableResource;
|
|
use App\Models\User\UserOrder;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class ShopOrderResource extends Resource
|
|
{
|
|
use TranslatableResource;
|
|
|
|
#[\Override]
|
|
protected static ?string $model = UserOrder::class;
|
|
|
|
#[\Override]
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-shopping-cart';
|
|
|
|
#[\Override]
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Shop';
|
|
|
|
#[\Override]
|
|
protected static ?string $slug = 'shop/orders';
|
|
|
|
public static string $translateIdentifier = 'shop-orders';
|
|
|
|
#[\Override]
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components(static::getForm());
|
|
}
|
|
|
|
public static function getForm(): array
|
|
{
|
|
return [
|
|
Select::make('user_id')
|
|
->label(__('User'))
|
|
->relationship('user', 'username')
|
|
->required(),
|
|
|
|
TextInput::make('product_name')
|
|
->label(__('Product'))
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
TextInput::make('amount')
|
|
->label(__('Amount'))
|
|
->numeric()
|
|
->required(),
|
|
|
|
TextInput::make('status')
|
|
->label(__('Status'))
|
|
->required()
|
|
->default('pending'),
|
|
|
|
TextInput::make('payment_method')
|
|
->label(__('Payment Method'))
|
|
->maxLength(255),
|
|
];
|
|
}
|
|
|
|
#[\Override]
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns(static::getTable());
|
|
}
|
|
|
|
public static function getTable(): array
|
|
{
|
|
return [
|
|
TextColumn::make('id')
|
|
->label(__('ID'))
|
|
->sortable(),
|
|
|
|
TextColumn::make('user.username')
|
|
->label(__('User'))
|
|
->searchable(),
|
|
|
|
TextColumn::make('product_name')
|
|
->label(__('Product'))
|
|
->searchable(),
|
|
|
|
TextColumn::make('amount')
|
|
->label(__('Amount')),
|
|
|
|
TextColumn::make('status')
|
|
->label(__('Status'))
|
|
->badge(),
|
|
|
|
TextColumn::make('created_at')
|
|
->label(__('Created'))
|
|
->dateTime(),
|
|
];
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListShopOrders::route('/'),
|
|
];
|
|
}
|
|
}
|