Files
autocrm/app/Filament/Tenant/Resources/CallResource.php
T
Vasyka 95aeecb932 i18n: fix widget heading, translate Select options from model consts, +40 keys
- LowStockTable: rename getHeading → getTableHeading (correct Filament API)
- Global I18n::opts() helper wraps Model::CONST values in __() so
  Select dropdowns show translated status/type/season/etc. labels
- Sed-transform ->options(X::CONST), ->options(array_combine(X::A,X::A)),
  and formatStateUsing(fn($s)=>X::CONST[$s]??$s) → wrap with __()
  (58 options + 10 combines + 7 formatStateUsing across 28 files)
- CalendarBoard: all 7 day names now via __() (was missing 4)
- calendar-board.blade: fix untranslated 'săptămâna curentă', 'capacitate',
  'rata confirmare', 'mediu', 'plin', 'Pod / Zi' / 'Mecanic / Zi'
- +40 RU/EN translations (Client & Auto, Maistru / Mecanic, Programat,
  Sosit, Finalizat, Anulat, Neprezentat, days of week, calendar KPIs)

All 306 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-16 06:42:16 +00:00

119 lines
4.4 KiB
PHP

<?php
namespace App\Filament\Tenant\Resources;
use App\Filament\Tenant\Resources\CallResource\Pages;
use App\Models\Tenant\Call;
use App\Models\Tenant\Client;
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 CallResource extends Resource
{
protected static ?string $model = Call::class;
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-phone';
public static function getNavigationLabel(): string
{
return __('nav.label.Apeluri');
}
public static function getNavigationGroup(): ?string
{
return __('nav.group.Marketing');
}
protected static ?string $modelLabel = null;
public static function getModelLabel(): string
{
return __('apel');
}
protected static ?string $pluralModelLabel = null;
public static function getPluralModelLabel(): string
{
return __('apeluri');
}
protected static ?int $navigationSort = 62;
public static function form(Schema $schema): Schema
{
return $schema->components([
Schemas\Components\Section::make(__('Apel'))
->columns(2)
->schema([
Forms\Components\DateTimePicker::make('called_at')->label(__('Data & ora'))->default(now())->required(),
Forms\Components\Select::make('direction')
->options(\App\Support\I18n::opts(Call::DIRECTIONS))
->default('incoming')
->required(),
Forms\Components\TextInput::make('phone')->label(__('Telefon'))->tel()->required()->maxLength(40),
Forms\Components\Select::make('status')
->options(\App\Support\I18n::opts(Call::STATUSES))
->default('answered')
->required(),
Forms\Components\TextInput::make('duration_sec')->label(__('Durată (sec)'))->numeric()->default(0),
Forms\Components\Select::make('client_id')
->label(__('Client'))
->options(fn () => Client::pluck('name', 'id'))
->searchable(),
]),
Forms\Components\Textarea::make('notes')->label(__('Notițe'))->columnSpanFull()->rows(2),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('called_at')->label(__('Data'))->dateTime('d.m.Y H:i')->sortable(),
Tables\Columns\TextColumn::make('direction')
->formatStateUsing(fn ($s) => Call::DIRECTIONS[$s] ?? $s)
->badge()
->colors([
'success' => ['incoming'],
'info' => ['outgoing'],
'danger' => ['missed'],
]),
Tables\Columns\TextColumn::make('phone')->copyable()->searchable(),
Tables\Columns\TextColumn::make('client.name')->label(__('Client'))->placeholder('—'),
Tables\Columns\TextColumn::make('duration_formatted')->label(__('Durată'))->state(fn (Call $r) => $r->duration_formatted),
Tables\Columns\TextColumn::make('status')
->formatStateUsing(fn ($s) => Call::STATUSES[$s] ?? $s)
->badge(),
])
->filters([
Tables\Filters\SelectFilter::make('direction')->options(\App\Support\I18n::opts(Call::DIRECTIONS)),
Tables\Filters\Filter::make('today')
->label(__('Astăzi'))
->query(fn ($q) => $q->whereDate('called_at', today())),
Tables\Filters\Filter::make('missed')
->label(__('Pierdute'))
->query(fn ($q) => $q->where('direction', 'missed')->orWhere('status', 'missed')),
])
->actions([
Actions\EditAction::make(),
Actions\DeleteAction::make(),
])
->defaultSort('called_at', 'desc');
}
public static function getPages(): array
{
return [
'index' => Pages\ListCalls::route('/'),
'create' => Pages\CreateCall::route('/create'),
'edit' => Pages\EditCall::route('/{record}/edit'),
];
}
}