You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
topnotch_website/app/Filament/Resources/CustomerReportResource.php

120 lines
4.0 KiB
PHTML

2 weeks ago
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\CustomerReportResource\Pages;
use App\Models\Customer;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
class CustomerReportResource extends Resource
{
protected static ?string $model = Customer::class;
protected static ?string $navigationGroup = 'Reports';
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationLabel = 'Customer Sales';
protected static ?int $navigationSort = 2;
public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('company_name')
->label('Customer')
->sortable()
->searchable()
->extraHeaderAttributes(['class' => 'w-full']),
2 weeks ago
Tables\Columns\TextColumn::make('subtotal')
->money('usd')
->alignRight()
->getStateUsing(function (Table $table, Model $record) {
return $record->getSubtotalAttribute(
$table->getFilter('created_at')->getState()['created_at'],
$table->getFilter('created_until')->getState()['created_until']
);
}),
Tables\Columns\TextColumn::make('gst')
->label('GST')
->money('usd')
->alignRight()
->getStateUsing(function (Table $table, Model $record) {
return $record->getGstAttribute(
$table->getFilter('created_at')->getState()['created_at'],
$table->getFilter('created_until')->getState()['created_until']
);
}),
Tables\Columns\TextColumn::make('pst')
->label('PST')
->money('usd')
->alignRight()
->getStateUsing(function (Table $table, Model $record) {
return $record->getPstAttribute(
$table->getFilter('created_at')->getState()['created_at'],
$table->getFilter('created_until')->getState()['created_until']
);
}),
Tables\Columns\TextColumn::make('total')
->money('usd')
->weight('bold')
->alignRight()
->getStateUsing(function (Table $table, Model $record) {
return $record->getTotalAttribute(
$table->getFilter('created_at')->getState()['created_at'],
$table->getFilter('created_until')->getState()['created_until']
);
}),
])
->filters([
Tables\Filters\Filter::make('created_at')
->form([
DatePicker::make('created_at')
->label('From date'),
]),
Tables\Filters\Filter::make('created_until')
->form([
DatePicker::make('created_until')
->label('Until date'),
]),
])
2 weeks ago
->actions([
])
->bulkActions([
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListCustomerReports::route('/'),
];
}
}