ifnex/04_Laravel/app/Filament/Resources/ShipmentResource/RelationManagers/PackagesRelationManager.php

68 lines
2.5 KiB
PHP

<?php
namespace App\Filament\Resources\ShipmentResource\RelationManagers;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
class PackagesRelationManager extends RelationManager
{
protected static string $relationship = 'packages';
protected static ?string $title = 'بسته‌ها';
protected static ?string $icon = 'heroicon-o-cube';
public function form(Form $form): Form
{
return $form->schema([
Forms\Components\TextInput::make('package_no')
->numeric()
->minValue(1)
->default(1)
->required()
->label('شماره بسته'),
Forms\Components\TextInput::make('weight')
->numeric()
->step(0.001)
->required()
->label('وزن واقعی (kg)'),
Forms\Components\TextInput::make('dimensions')
->placeholder('مثلاً 25*15*3')
->required()
->label('ابعاد (L*W*H)'),
Forms\Components\Textarea::make('content_description')
->rows(2)
->label('شرح محتوا'),
]);
}
public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('package_no')->label('#')->sortable(),
Tables\Columns\TextColumn::make('weight')->label('وزن واقعی')->suffix(' kg')->sortable(),
Tables\Columns\TextColumn::make('dimensions')->label('ابعاد'),
Tables\Columns\TextColumn::make('volumetric_weight')->label('وزن حجمی')->suffix(' kg'),
Tables\Columns\TextColumn::make('chargeable_weight')->label('وزن محاسبه‌ای')->suffix(' kg')->badge()->color('warning'),
Tables\Columns\TextColumn::make('content_description')->label('شرح محتوا')->limit(40)->toggleable(),
])
->defaultSort('package_no', 'asc')
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}