3911012c65
Broad sweep across the whole codebase:
- Blade views (39 files, 315 wraps): tag-text and title/placeholder/alt
attributes wrapped with {{ __() }}. Excludes scripts, styles, @php,
@verbatim, {{ }}, {!! !!}, comments to avoid touching interpolations.
- PHP (54 files, 179 wraps): array 'key' => 'RO value' patterns and
list items with diacritics wrapped with __(). Reverted __() inside
const arrays (PHP disallows non-constant expressions).
- Added 269 new keys to lang/{ru,en}.json (identity fallback for
unknowns → 161 human RU + 163 EN translations added for the most
common enums, stages, roles, statuses, payment methods, vehicle
categories, warehouse, portal, form actions.
Missing translations fall back to RO so the UI never breaks. All 306
tests pass; view cache compiles cleanly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
96 lines
3.6 KiB
PHP
96 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources\UserResource\RelationManagers;
|
|
|
|
use App\Auth\Permissions;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Spatie\Permission\Models\Permission;
|
|
|
|
class PermissionOverridesRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'permissionOverrides';
|
|
|
|
protected static ?string $title = null;
|
|
|
|
public static function getTitle(\Illuminate\Database\Eloquent\Model $ownerRecord, string $pageClass): string
|
|
{
|
|
return __('Excepții drepturi');
|
|
}
|
|
|
|
protected static string|\BackedEnum|null $icon = 'heroicon-o-shield-exclamation';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Schemas\Components\Section::make(__('Excepție'))
|
|
->columns(2)
|
|
->schema([
|
|
Forms\Components\Select::make('permission_id')
|
|
->label(__('Drept'))
|
|
->required()
|
|
->searchable()
|
|
->options(fn () => Permission::orderBy('name')->pluck('name', 'id'))
|
|
->columnSpanFull(),
|
|
Forms\Components\Select::make('mode')
|
|
->required()
|
|
->options(['grant' => __('GRANT — adaugă dreptul'), 'deny' => 'DENY — interzice dreptul'])
|
|
->default('grant'),
|
|
Forms\Components\DatePicker::make('expires_at')
|
|
->label(__('Expiră la (opțional)'))
|
|
->minDate(now()),
|
|
Forms\Components\Textarea::make('reason')
|
|
->label(__('Motiv'))
|
|
->columnSpanFull()
|
|
->placeholder(__('Ex: lockdown temporar; acces pentru audit; etc.'))
|
|
->rows(2),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('mode')
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('permission.name')
|
|
->label(__('Drept'))
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('mode')
|
|
->badge()
|
|
->colors(['success' => 'grant', 'danger' => 'deny'])
|
|
->formatStateUsing(fn ($state) => strtoupper($state)),
|
|
Tables\Columns\TextColumn::make('reason')
|
|
->limit(40)
|
|
->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('expires_at')
|
|
->label(__('Expiră'))
|
|
->date()
|
|
->placeholder(__('niciodată'))
|
|
->color(fn ($record) => $record?->isExpired() ? 'danger' : 'gray'),
|
|
Tables\Columns\TextColumn::make('grantedBy.name')
|
|
->label(__('Acordat de'))
|
|
->placeholder('—')
|
|
->toggleable(),
|
|
])
|
|
->headerActions([
|
|
Actions\CreateAction::make()
|
|
->mutateDataUsing(fn (array $data) => array_merge($data, [
|
|
'granted_at' => now(),
|
|
'granted_by_id' => auth()->id(),
|
|
])),
|
|
])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->defaultSort('granted_at', 'desc');
|
|
}
|
|
}
|