Files
autocrm/app/Filament/Tenant/Resources/PostResource.php
T
Vasyka 7077fff3b3 feat(i18n): convert 38 hardcoded static labels + safe blade wrap + 226 keys
- 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>
2026-07-15 06:17:10 +00:00

120 lines
4.3 KiB
PHP

<?php
namespace App\Filament\Tenant\Resources;
use App\Auth\Permissions;
use App\Filament\Tenant\Resources\PostResource\Pages;
use App\Models\Tenant\Post;
use App\Models\Tenant\User;
use Filament\Actions;
use Filament\Forms;
use Filament\Resources\Resource;
use Filament\Schemas;
use Filament\Schemas\Schema;
use Filament\Tables;
use Filament\Tables\Table;
class PostResource extends Resource
{
protected static ?string $model = Post::class;
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-wrench-screwdriver';
public static function getNavigationLabel(): string
{
return __('nav.label.Posturi de lucru');
}
public static function getNavigationGroup(): ?string
{
return __('nav.group.Admin');
}
protected static ?string $modelLabel = null;
public static function getModelLabel(): string
{
return __('pod');
}
protected static ?string $pluralModelLabel = null;
public static function getPluralModelLabel(): string
{
return __('posturi de lucru');
}
protected static ?int $navigationSort = 76;
public static function canViewAny(): bool
{
return auth()->user()?->canDo(Permissions::ADMIN_SETTINGS_EDIT) ?? false;
}
public static function form(Schema $schema): Schema
{
return $schema->components([
Schemas\Components\Section::make(__('Pod / Spațiu lucru'))
->columns(2)
->schema([
Forms\Components\TextInput::make('name')
->label(__('Nume'))
->required()
->maxLength(80)
->placeholder(__('Ex: Pod 1, Curte 1, Atelier electric')),
Forms\Components\ColorPicker::make('color')
->default('#3b82f6'),
Forms\Components\TextInput::make('hours_per_day')
->label(__('Ore disponibile / zi'))
->numeric()
->step(0.5)
->default(10)
->helperText(__('Capacitatea zilnică în ore')),
Forms\Components\Select::make('default_master_id')
->label(__('Mecanic implicit'))
->options(fn () => User::where('status', 'active')->pluck('name', 'id'))
->searchable()
->placeholder(__('Niciun mecanic implicit'))
->helperText(__('Va fi pre-completat când creezi o programare pentru acest pod')),
Forms\Components\TextInput::make('description')
->label(__('Descriere'))
->maxLength(255)
->placeholder(__('Ex: cu lift, fără lift, doar diagnoză...'))
->columnSpanFull(),
Forms\Components\TextInput::make('sort_order')
->numeric()
->default(100),
Forms\Components\Toggle::make('is_active')->label(__('Activ'))->default(true),
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
Tables\Columns\ColorColumn::make('color'),
Tables\Columns\TextColumn::make('hours_per_day')->label(__('Ore/zi'))->sortable(),
Tables\Columns\TextColumn::make('defaultMaster.name')->label(__('Mecanic implicit'))->placeholder('—'),
Tables\Columns\TextColumn::make('description')->placeholder('—')->limit(40)->toggleable(),
Tables\Columns\TextColumn::make('appointments_count')->counts('appointments')->label(__('Programări'))->badge(),
Tables\Columns\ToggleColumn::make('is_active')->label(__('Activ')),
])
->actions([
Actions\EditAction::make(),
Actions\DeleteAction::make(),
])
->defaultSort('sort_order');
}
public static function getPages(): array
{
return [
'index' => Pages\ListPosts::route('/'),
'create' => Pages\CreatePost::route('/create'),
'edit' => Pages\EditPost::route('/{record}/edit'),
];
}
}