You've already forked Atomcms-edit
Initial commit
This commit is contained in:
+137
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Shop;
|
||||
|
||||
use App\Filament\Resources\Shop\PayPalTransactionResource\Pages\ListPayPalTransactions;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Shop\WebsitePaypalTransaction;
|
||||
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 PayPalTransactionResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $model = WebsitePaypalTransaction::class;
|
||||
|
||||
protected static string $translateIdentifier = 'paypal-transactions';
|
||||
|
||||
#[\Override]
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-credit-card';
|
||||
|
||||
#[\Override]
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Shop';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $slug = 'shop/paypal-transactions';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $modelLabel = 'PayPal Transaction';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $pluralModelLabel = 'PayPal Transactions';
|
||||
|
||||
#[\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('transaction_id')
|
||||
->label(__('Transaction ID'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
TextInput::make('status')
|
||||
->label(__('Status'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
TextInput::make('description')
|
||||
->label(__('Description'))
|
||||
->maxLength(512),
|
||||
|
||||
TextInput::make('amount')
|
||||
->label(__('Amount'))
|
||||
->numeric()
|
||||
->required(),
|
||||
|
||||
TextInput::make('currency')
|
||||
->label(__('Currency'))
|
||||
->maxLength(255)
|
||||
->default('USD'),
|
||||
];
|
||||
}
|
||||
|
||||
#[\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('transaction_id')
|
||||
->label(__('Transaction ID'))
|
||||
->searchable()
|
||||
->limit(20),
|
||||
|
||||
TextColumn::make('status')
|
||||
->label(__('Status'))
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'completed' => 'success',
|
||||
'pending' => 'warning',
|
||||
'failed' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
|
||||
TextColumn::make('description')
|
||||
->label(__('Description'))
|
||||
->limit(50),
|
||||
|
||||
TextColumn::make('amount')
|
||||
->label(__('Amount'))
|
||||
->money(fn (WebsitePaypalTransaction $record): string => $record->currency),
|
||||
|
||||
TextColumn::make('currency')
|
||||
->label(__('Currency')),
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->label(__('Created'))
|
||||
->dateTime(),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListPayPalTransactions::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user