Add all files
This commit is contained in:
56
app/Admin/Resources/UserResource/Pages/ShowInvoices.php
Normal file
56
app/Admin/Resources/UserResource/Pages/ShowInvoices.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Resources\UserResource\Pages;
|
||||
|
||||
use App\Admin\Resources\InvoiceResource;
|
||||
use App\Admin\Resources\UserResource;
|
||||
use Filament\Resources\Pages\ManageRelatedRecords;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ShowInvoices extends ManageRelatedRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected static string $relationship = 'invoices';
|
||||
|
||||
protected static ?string $navigationIcon = 'ri-bill-line';
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Invoices';
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('product.name')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('formattedTotal')->label('Total'),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
// Make first letter uppercase
|
||||
->formatStateUsing(fn (string $state): string => ucfirst($state))
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'paid' => 'success',
|
||||
'pending' => 'warning',
|
||||
default => 'danger',
|
||||
}),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'paid' => 'Paid',
|
||||
'pending' => 'Pending',
|
||||
'cancelled' => 'Cancelled',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make()->url(fn ($record) => InvoiceResource::getUrl('edit', ['record' => $record])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user