I had troubles when I use join queries like this:
`
$contract->actions()->orderBy('action_types.name, 'DESC')
->join('action_types', 'action_types.id', '=' , 'actions.type_id')
->paginate($data->perPage, page: $data->page);
Join neccessary for ordering by nested table. So after this query executing, I have to take names data from model ActionTypes. So, I already have this data by join query, but this data saved in model Action. And when i try call Action->actionType->name query executing again. I want to avoid this and save data from join to nested model. How i can do this? Thanks for any help.
I tried save data from parent table but this may take many time;
I tried use with method but this dont ordering my data correctly.