silent-auction/app/Filament/Resources/CheckoutResource.php

102 lines
3.1 KiB
PHP
Raw Permalink Normal View History

2022-08-06 15:39:24 -04:00
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\CheckoutResource\Pages;
use App\Filament\Resources\CheckoutResource\RelationManagers;
use App\Models\Checkout;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
2022-08-07 12:48:05 -04:00
use Filament\Tables\Columns\BooleanColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
2022-09-28 07:52:27 -04:00
use Filament\Forms\Components\Select;
2022-08-07 12:48:05 -04:00
use Filament\Forms\Components\Toggle;
2022-09-28 07:52:27 -04:00
use App\Models\Bidders;
use App\Models\PaymentMethods;
2022-08-06 15:39:24 -04:00
class CheckoutResource extends Resource
{
protected static ?string $model = Checkout::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
2022-08-07 13:07:31 -04:00
protected static ?string $navigationGroup = 'Silent Auction';
2022-08-06 15:39:24 -04:00
public static function form(Form $form): Form
{
return $form
->schema([
2022-09-28 07:52:27 -04:00
Select::make('bidder_num')
->label('Bidder')
->options(
Bidders::orderBy('bidder_assigned_number')
->pluck('bidder_assigned_number', 'idbidders')
)
->searchable(),
TextInput::make('winnertotal')
->label('Total Amount')
->mask(
fn (TextInput\Mask $mask) => $mask->money(
2023-03-16 12:39:15 -04:00
prefix: '$',
thousandsSeparator: ',',
decimalPlaces: 2,
isSigned: false
2022-09-28 07:52:27 -04:00
)
),
Select::make('payment_method')
->label('Payment Method')
->options(PaymentMethods::all()->pluck('pm_name', 'pm_id'))
->searchable(),
2022-08-06 15:39:24 -04:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
2022-09-04 13:57:38 -04:00
TextColumn::make('bidders.bidder_assigned_number')
->label('Bidder Number')
->sortable(),
TextColumn::make('winnertotal')
->label('Total Amount')
->money('usd', 'true')
->sortable(),
TextColumn::make('paymentMethod.pm_name')
->label('Payment Method')
->sortable(),
2022-08-06 15:39:24 -04:00
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
2022-09-26 19:12:15 -04:00
])
->defaultSort('bidders.bidder_assigned_number');
2022-08-06 15:39:24 -04:00
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListCheckouts::route('/'),
'create' => Pages\CreateCheckout::route('/create'),
'edit' => Pages\EditCheckout::route('/{record}/edit'),
];
}
}