fix: revert client_id to options() — relationship() broke initial list loading
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -84,18 +84,14 @@ class WorkOrderResource extends Resource
|
|||||||
Forms\Components\Select::make('urgency')->label(__('Urgență'))
|
Forms\Components\Select::make('urgency')->label(__('Urgență'))
|
||||||
->options(\App\Support\I18n::opts(\App\Models\Tenant\PricingCoefficient::URGENCY))->default('normal')->required(),
|
->options(\App\Support\I18n::opts(\App\Models\Tenant\PricingCoefficient::URGENCY))->default('normal')->required(),
|
||||||
Forms\Components\Select::make('client_id')->label(__('Client'))
|
Forms\Components\Select::make('client_id')->label(__('Client'))
|
||||||
->relationship('client', 'name')
|
->options(fn () => Client::orderBy('name')->pluck('name', 'id'))
|
||||||
->getSearchResultsUsing(fn (string $query) =>
|
|
||||||
Client::where(fn ($q) => $q
|
|
||||||
->where('name', 'like', "%{$query}%")
|
|
||||||
->orWhere('phone', 'like', "%{$query}%"))
|
|
||||||
->limit(30)->pluck('name', 'id'))
|
|
||||||
->searchable()->live()->required()->columnSpan(2)
|
->searchable()->live()->required()->columnSpan(2)
|
||||||
->createOptionForm([
|
->createOptionForm([
|
||||||
Forms\Components\TextInput::make('name')->label(__('Nume'))->required(),
|
Forms\Components\TextInput::make('name')->label(__('Nume'))->required(),
|
||||||
Forms\Components\TextInput::make('phone')->label(__('Telefon')),
|
Forms\Components\TextInput::make('phone')->label(__('Telefon')),
|
||||||
Forms\Components\TextInput::make('email')->label(__('Email'))->email(),
|
Forms\Components\TextInput::make('email')->label(__('Email'))->email(),
|
||||||
]),
|
])
|
||||||
|
->createOptionUsing(fn (array $data) => Client::create($data)->id),
|
||||||
Forms\Components\Select::make('vehicle_id')->label(__('Auto'))
|
Forms\Components\Select::make('vehicle_id')->label(__('Auto'))
|
||||||
->options(fn (Get $get) => $get('client_id')
|
->options(fn (Get $get) => $get('client_id')
|
||||||
? Vehicle::where('client_id', $get('client_id'))->get()
|
? Vehicle::where('client_id', $get('client_id'))->get()
|
||||||
|
|||||||
Reference in New Issue
Block a user