75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Resources\InvoiceResource\RelationManagers;
|
|
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Support\RawJs;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class TransactionsRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'transactions';
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\Select::make('gateway.name')
|
|
->label('Gateway')
|
|
->relationship('gateway', 'name')
|
|
->searchable()
|
|
->preload()
|
|
->placeholder('Select the gateway'),
|
|
Forms\Components\TextInput::make('transaction_id')
|
|
->label('Transaction ID'),
|
|
Forms\Components\TextInput::make('amount')
|
|
->label('Amount')
|
|
->numeric()
|
|
->mask(RawJs::make(
|
|
<<<'JS'
|
|
$money($input, '.', '', 2)
|
|
JS
|
|
))
|
|
->required(),
|
|
Forms\Components\TextInput::make('fee')
|
|
->numeric()
|
|
->mask(RawJs::make(
|
|
<<<'JS'
|
|
$money($input, '.', '', 2)
|
|
JS
|
|
))
|
|
->label('Fee'),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('transaction_id')
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('gateway.name')->label('Gateway'),
|
|
Tables\Columns\TextColumn::make('transaction_id'),
|
|
Tables\Columns\TextColumn::make('formattedAmount')->label('Amount'),
|
|
Tables\Columns\TextColumn::make('formattedFee')->label('Fee'),
|
|
Tables\Columns\TextColumn::make('created_at'),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
Tables\Actions\CreateAction::make(),
|
|
])
|
|
->actions([
|
|
Tables\Actions\DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|