100 lines
3.8 KiB
PHP
100 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\FeedPurchases\Tables;
|
|
|
|
use App\Filament\Actions\Cheerful\DeleteAction;
|
|
use App\Filament\Actions\Cheerful\ForceDeleteAction;
|
|
use App\Filament\Actions\Cheerful\RestoreAction;
|
|
use App\Filament\Actions\DefaultBulkActions;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\TrashedFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class FeedPurchasesTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('reference_number')
|
|
->label('No. Referensi')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
TextColumn::make('purchase_date')
|
|
->label('Tanggal Belanja')
|
|
->date('l, d F Y')
|
|
->sortable(),
|
|
|
|
TextColumn::make('items_summary')
|
|
->label('Item Pakan')
|
|
->getStateUsing(function ($record): array {
|
|
return $record->items
|
|
->map(function ($item) {
|
|
$feedName = $item->feed?->name ?? '-';
|
|
$feedUnit = $item->feed?->unit?->name ?? '-';
|
|
$quantity = number_format($item->quantity, 0, ',', '.');
|
|
$subtotal = $item->formatted_subtotal;
|
|
|
|
return sprintf(
|
|
'<div class="flex items-center justify-between gap-1 p-1">
|
|
<div class="flex flex-col">
|
|
<span class="font-semibold text-gray-900 dark:text-gray-100">
|
|
%s
|
|
</span>
|
|
<span class="text-xs text-gray-500">
|
|
x%s %s
|
|
</span>
|
|
</div>
|
|
|
|
<div class="text-sm whitespace-nowrap">
|
|
Rp %s
|
|
</div>
|
|
</div>',
|
|
e($feedName),
|
|
$quantity,
|
|
$feedUnit,
|
|
$subtotal,
|
|
);
|
|
})
|
|
->toArray();
|
|
})
|
|
->listWithLineBreaks()
|
|
->html()
|
|
->toggleable(),
|
|
|
|
TextColumn::make('total_price')
|
|
->label('Total Harga')
|
|
->money('IDR', decimalPlaces: 0)
|
|
->sortable(),
|
|
|
|
TextColumn::make('created_at')
|
|
->label('Dibuat')
|
|
->dateTime('d/m/Y H:i')
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
TrashedFilter::make()
|
|
->native(false),
|
|
])
|
|
->recordActions([
|
|
DeleteAction::make(),
|
|
|
|
ForceDeleteAction::make(),
|
|
|
|
RestoreAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
...DefaultBulkActions::make('Belanja Pakan'),
|
|
]),
|
|
])
|
|
->emptyStateIcon(Heroicon::Banknotes)
|
|
->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.')
|
|
->defaultSort('created_at', 'desc')
|
|
->deferFilters(false);
|
|
}
|
|
}
|