D
D
DenisCern2021-04-26 20:35:19
Laravel
DenisCern, 2021-04-26 20:35:19

How to pass parameters for table sorting when join?

In a Laravel project, I get data from two tables with a query.

$tasks = new TaskModel();
$query= $tasks->join('user_models', 'user_models.id', '=', 'task_models.userId'); 
$itemsArray = $query->sortable()->paginate(3,['user_models.name', 'user_models.email', 'task_models.task','task_models.status']);


Sorting data by columns using Kyslik. Sorting works only on fields from the TaskModel(), and does not work on fields from another table. As I understand it, when accessing via join, the query does not receive data about the sortable fields of the joined table, since the sortable() method only affects TaskModel().

Please tell me how to correctly apply the sortable () method so that sorting is done by all the necessary fields. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question