Implementing Car Selection Logic in without using Session
I spent the entire day attempting to implement this logic without success. I have two models: 'CAR' and 'car_tenancy.' I only add car names to the 'car' resource. Currently, when I'm working on 'car_tenancy,' I want to ensure that if I select a car and return to create another entry, I shouldn't see the previously selected car. I've implemented the logic using 'session,' but I know it's not suitable for production. Could someone suggest an alternative? Here's a look at my code:
Solution:Jump to solution
Yes Solved ``` Forms\Components\Select::make('car_id')
->options(function () {
$allocatedCars = CarTenancy::pluck('car_id')->toArray();
// Fetch available cars that are not allocated to any driver...
3 Replies
Can someone please help
So selected cars are the cars that already exist in another table? Why don’t you use a DB query to fetch them?
Solution
Yes Solved