7077fff3b3
- Convert all remaining static \$modelLabel/\$pluralModelLabel to getter methods with __() (AppointmentResource, WorkOrderResource, MasterResource, ServiceTemplateResource, LaborResource, and 33 others) - Safe blade wrap v2 (37 files, 201 wraps): fixed the regex to not match `->`, `=>`, `!<` — previous aggressive pass broke @if directives - Bulk-translate lowercase model-label keys (programări, fișe lucru, tehnicieni, șabloane servicii, norme-ore, etc.) — these were the RO strings appearing in page titles/breadcrumbs - Add human RU/EN for mechanic-kpi (Mecanic/Lucrări/Norma ore/etc.) and calendar-board words Tests 306 green. Blade compiles cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
136 lines
5.2 KiB
PHP
136 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources;
|
|
|
|
use App\Filament\Tenant\Resources\DealResource\Pages;
|
|
use App\Models\Tenant\Client;
|
|
use App\Models\Tenant\Deal;
|
|
use App\Models\Tenant\Lead;
|
|
use App\Models\Tenant\User;
|
|
use App\Models\Tenant\Vehicle;
|
|
use Filament\Forms;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Actions;
|
|
use Filament\Schemas;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class DealResource extends Resource
|
|
{
|
|
protected static ?string $model = Deal::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-funnel';
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return __('nav.label.Pipeline (tabel)');
|
|
}
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('nav.group.CRM');
|
|
}
|
|
|
|
public static function shouldRegisterNavigation(): bool
|
|
{
|
|
return false; // PipelineBoard page is the canonical entry; this resource keeps CRUD routes for edit/create.
|
|
}
|
|
|
|
protected static ?string $modelLabel = null;
|
|
|
|
public static function getModelLabel(): string
|
|
{
|
|
return __('deal');
|
|
}
|
|
|
|
protected static ?string $pluralModelLabel = null;
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return __('deal-uri');
|
|
}
|
|
|
|
protected static ?int $navigationSort = 6;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Schemas\Components\Section::make(__('Detalii'))
|
|
->columns(2)
|
|
->schema([
|
|
Forms\Components\Select::make('client_id')
|
|
->label(__('Client'))
|
|
->options(fn () => Client::pluck('name', 'id'))
|
|
->searchable()
|
|
->required(),
|
|
Forms\Components\Select::make('vehicle_id')
|
|
->label(__('Auto'))
|
|
->options(fn (Schemas\Components\Utilities\Get $get) => $get('client_id')
|
|
? Vehicle::where('client_id', $get('client_id'))->pluck('plate', 'id')
|
|
: [])
|
|
->searchable(),
|
|
Forms\Components\TextInput::make('name')->label(__('Subiect'))->required()->maxLength(160),
|
|
Forms\Components\TextInput::make('price')->label(__('Valoare'))->numeric()->default(0),
|
|
Forms\Components\Select::make('stage')
|
|
->options(Deal::STAGES)
|
|
->default('new')
|
|
->required(),
|
|
Forms\Components\Select::make('source')
|
|
->options(Lead::SOURCES)
|
|
->searchable(),
|
|
Forms\Components\Select::make('assigned_to')
|
|
->label(__('Responsabil'))
|
|
->options(fn () => User::pluck('name', 'id'))
|
|
->searchable(),
|
|
]),
|
|
Forms\Components\Textarea::make('note')->label(__('Notițe'))->columnSpanFull()->rows(3),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('id')->label('#')->sortable(),
|
|
Tables\Columns\TextColumn::make('name')->label(__('Subiect'))->searchable()->limit(40),
|
|
Tables\Columns\TextColumn::make('client.name')->label(__('Client'))->searchable(),
|
|
Tables\Columns\TextColumn::make('vehicle.plate')->label(__('Auto'))->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('stage')
|
|
->formatStateUsing(fn ($state) => Deal::STAGES[$state] ?? $state)
|
|
->badge()
|
|
->colors([
|
|
'gray' => ['new'],
|
|
'info' => ['contact', 'agree'],
|
|
'warning' => ['scheduled', 'arrived', 'in_work'],
|
|
'success' => ['done'],
|
|
'danger' => ['lost'],
|
|
]),
|
|
Tables\Columns\TextColumn::make('price')->money('MDL')->sortable(),
|
|
Tables\Columns\TextColumn::make('source')->label(__('Sursă'))->formatStateUsing(fn ($state) => Lead::SOURCES[$state] ?? $state)->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('assignedTo.name')->label(__('Responsabil'))->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('created_at')->date()->sortable(),
|
|
])
|
|
->filters([
|
|
Tables\Filters\SelectFilter::make('stage')->options(Deal::STAGES),
|
|
Tables\Filters\SelectFilter::make('assigned_to')
|
|
->label(__('Responsabil'))
|
|
->options(fn () => User::pluck('name', 'id')),
|
|
])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListDeals::route('/'),
|
|
'create' => Pages\CreateDeal::route('/create'),
|
|
'edit' => Pages\EditDeal::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|