Files
autocrm/app/Filament/Tenant/Resources/PostResource.php
T
Vasyka f7fc69077b feat(i18n): wrap 1103 hardcoded UI strings across Filament with __()
- Convert static $modelLabel/$pluralModelLabel/$title to getter methods
- Wrap ->label()/->placeholder()/->helperText()/->description()/->title()/->body() args
- Wrap Section::make()/Fieldset::make()/Notification::make()->title() args
- Fix RelationManagers::getTitle() signature to match parent (Model, string)
- Fix Pages::getTitle() to instance method (BasePage::getTitle is non-static)
- Extend lang/ru.json + lang/en.json with 700+ common terms; identity fallback for the rest
- Remove duplicate getters in 5 resources that had manual getModelLabel already

All 306 tests pass. Missing translations fall back to the RO key so the UI never breaks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-15 05:04:24 +00:00

115 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 = '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'),
];
}
}