Select with multiple doesn't show previously selected record because they are softdeleted
I know it is because of Laravel eloquent and i could change the query to withTrashed but the hard part is that the options should not list softdeleted, because in the app they are "archived", but the previously selected options should. I can make the "same" option work in relations that store a id on the table using getOptionLabelUsing, i tried using getOptionLabelsUsing on the multiple form Select but to no affect, any on how to make it work?
5 Replies
Just modify the query, to search as normal but with a orWhere('id', '=', $state)
i.e.
the thing is that i keep getting null on the $state variable, maybe be cause the $state is set after que query is finished? Maybe because the state is not stored in the table in the db like the non pivot relations
i was thinking about trying to use livewire to check if it is a instance of edit, then modify the query to force the load the relations listed in the pivot
Maybe see if $record can be used? else try $livewire and also make the select a live()
well, $record exists and points to the current record on edit and on create returns null as expected.
if anyone falls on this thread, here's a example of a bad query you could do to solve the problem