billyma121182
Odd issue with form select on virtual column
So I have a virtual column in my orders model defined as below:
protected function TitleAndID(): Attribute
{
return Attribute::make(
get: fn() => $this->OrderID . ' - ' . $this->OrderTitle,
);
}
I can access it fine in the in form select shown below
Forms\Components\Select::make('DetailOrderID')->label('Order full')
->options(Order::all()->pluck('TitleAndID', 'OrderID'))
->preload()
->live()
->searchable()
If I try to filter the options then access the TitleAndID column as below I get an error "Unknown column 'TitleAndID' in field list".
What am I missing?
Forms\Components\Select::make('DetailOrderID')
->label('Order')
->options(fn (Get $get): Collection => Order::query()
->where('OrderProjectID', $get('item.ItemProjectID'))
->pluck('TitleAndID', 'OrderID')),
10 replies
Concating Fields in Select Option
I need to add the Project Name and IDs to select options. I have used a mutator in the model shown below.
protected function NameAndID(): Attribute
{
return Attribute::make(
get: fn() => $this->ProjectID . ' - ' . $this->ProjectName,
);
}
The NameAndID column works great in the form but not the filters where
SelectFilter::make('PaymentProjectID')->relationship('project', 'NameAndID')->label('Project'),
Gives me
Column not found: 1054 Unknown column 'project.NameAndID' in 'field list'
Any advise gratefully received!
9 replies
Infolist link not clickable
I have added a link to an infolist using the code from the documentation and it there are no errors its just not creating a clickable link. Sure I'm jusrt being dumb but cant see why...
Thanks anybody!
TextEntry::make('Add Item')
->url(fn (Order $record): string => route('createItem', ['id' => $record])),
5 replies