76 lines
3.2 KiB
PHP
76 lines
3.2 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 ReviewsRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'reviews';
|
|
|
|
protected static ?string $title = 'تاریخچه بررسی';
|
|
|
|
protected static ?string $icon = 'heroicon-o-arrow-path';
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
// این رکوردها توسط ShipmentReviewService ایجاد میشوند؛ فرم فقط برای مشاهده/یادداشت
|
|
return $form->schema([
|
|
Forms\Components\TextInput::make('revision_no')
|
|
->label('شماره بازبینی')
|
|
->disabled(),
|
|
Forms\Components\Select::make('decision')
|
|
->options([
|
|
'pending' => 'در انتظار',
|
|
'changes_requested' => 'درخواست اصلاح',
|
|
'approved' => 'تأیید شده',
|
|
'rejected' => 'رد شده',
|
|
])
|
|
->label('تصمیم')
|
|
->disabled(),
|
|
Forms\Components\Textarea::make('reason')
|
|
->rows(3)
|
|
->label('دلیل')
|
|
->disabled(),
|
|
Forms\Components\Textarea::make('notes')
|
|
->rows(3)
|
|
->label('یادداشت'),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('revision_no')->label('نسخه')->sortable()->badge()->color('gray'),
|
|
Tables\Columns\TextColumn::make('decision')
|
|
->label('تصمیم')
|
|
->badge()
|
|
->color(fn (string $state): string => match ($state) {
|
|
'pending' => 'warning',
|
|
'changes_requested' => 'info',
|
|
'approved' => 'success',
|
|
'rejected' => 'danger',
|
|
default => 'gray',
|
|
})
|
|
->formatStateUsing(fn (string $state): string => match ($state) {
|
|
'pending' => 'در انتظار',
|
|
'changes_requested' => 'درخواست اصلاح',
|
|
'approved' => 'تأیید شده',
|
|
'rejected' => 'رد شده',
|
|
default => $state,
|
|
}),
|
|
Tables\Columns\TextColumn::make('reason')->label('دلیل')->limit(50)->toggleable(),
|
|
Tables\Columns\TextColumn::make('notes')->label('یادداشت')->limit(50)->toggleable(),
|
|
Tables\Columns\TextColumn::make('reviewedBy.name')->label('بررسیکننده')->toggleable(),
|
|
Tables\Columns\TextColumn::make('reviewed_at')->label('تاریخ بررسی')->dateTime('Y/m/d H:i')->toggleable(),
|
|
])
|
|
->defaultSort('revision_no', 'desc')
|
|
// فقط مشاهده — این رکوردها توسط ShipmentReviewService ایجاد/نهایی میشوند
|
|
->headerActions([]);
|
|
}
|
|
} |