change datatable to accept multisort
This commit is contained in:
@@ -57,12 +57,17 @@ class DataTableInput
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Sort|null
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSorting(): ?Sort
|
||||
public function getSorting(): ?array
|
||||
{
|
||||
return !empty($this->sorting) ?
|
||||
new Sort($this->sorting[0]->id, $this->sorting[0]->desc, $this->allowedSortings) : null;
|
||||
$sorts = [];
|
||||
if (!empty($this->sorting)){
|
||||
foreach ($this->sorting as $sort) {
|
||||
$sorts[] = new Sort($sort->id, $sort->desc, $this->allowedSortings);
|
||||
}
|
||||
}
|
||||
return $sorts == [] ? null : $sorts;
|
||||
}
|
||||
|
||||
public function getRelations(): array
|
||||
|
||||
@@ -83,7 +83,10 @@ class DataTableService
|
||||
}
|
||||
|
||||
$sorting = $this->dataTableInput->getSorting();
|
||||
$query = (new ApplySort($query, $sorting))->apply();
|
||||
foreach ($sorting as $sort){
|
||||
$query = (new ApplySort($query, $sort))->apply();
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user