Files
core/src/Shipping/Filament/Resources/ManifestResource.php
T

67 lines
2.2 KiB
PHP
Raw Normal View History

<?php
namespace Modules\Core\Shipping\Filament\Resources;
use Filament\Actions\ViewAction;
use Filament\Resources\Resource;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Modules\Core\Shipping\Filament\Resources\ManifestResource\Pages\ListManifests;
use Modules\Core\Shipping\Filament\Resources\ManifestResource\Pages\ViewManifest;
use Modules\Core\Shipping\Filament\Resources\ManifestResource\RelationManagers\ShipmentsRelationManager;
use Modules\Core\Shipping\Models\Manifest;
/**
* Issued manifests — Modules\Core\Shipping\Models\Manifest is the only
* record of "which shipments were on manifest X, and when" this codebase
* keeps; ACS's own ACS_Issue_Pickup_List call returns nothing beyond a
* reference number, so there is nothing to re-fetch from the carrier
* later (see that model's own docblock). Complements
* Modules\Core\Shipping\Filament\Resources\ShipmentResource, which only
* ever shows shipments NOT YET on a manifest.
*/
class ManifestResource extends Resource
{
protected static ?string $model = Manifest::class;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-clipboard-document-list';
protected static string | \UnitEnum | null $navigationGroup = 'Sales';
protected static ?string $navigationLabel = 'Issued Manifests';
protected static ?string $modelLabel = 'Manifest';
protected static ?int $navigationSort = 101;
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('carrier')->badge(),
TextColumn::make('reference')->label('Reference')->copyable(),
TextColumn::make('shipment_count')->label('Shipments'),
TextColumn::make('issued_at')->label('Issued')->dateTime(),
])
->recordActions([
ViewAction::make(),
])
->defaultSort('issued_at', 'desc');
}
public static function getRelations(): array
{
return [
ShipmentsRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => ListManifests::route('/'),
'view' => ViewManifest::route('/{record}'),
];
}
}