Allow filtering and sorting of documents
This commit is contained in:
parent
2aef51aeb4
commit
dceee1adbc
|
|
@ -486,6 +486,21 @@ class ClientController extends BaseController
|
|||
})
|
||||
->orWhereHasMorph('documentable', [Client::class], function ($query) use ($client) {
|
||||
$query->where('id', $client->id);
|
||||
})
|
||||
->when(strlen($request->input('filter','')) > 1, function ($query) use ($request) {
|
||||
$query->where('name', 'like', '%'.$request->input('filter','').'%');
|
||||
})
|
||||
->when(strlen($request->input('sort','')) > 1, function ($query) use ($request) {
|
||||
|
||||
$sort_col = explode('|', $request->input('sort',''));
|
||||
|
||||
if (!is_array($sort_col) || count($sort_col) != 2 || !in_array($sort_col[0], \Illuminate\Support\Facades\Schema::getColumnListing($query->getModel()->getTable()))) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
|
||||
return $query->orderBy($sort_col[0], $dir);
|
||||
|
||||
});
|
||||
|
||||
return $this->listResponse($documents);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class PreviewReport implements ShouldQueue
|
|||
$report = $export->run();
|
||||
}
|
||||
|
||||
Cache::put($this->hash, base64_encode($report), 60 * 60);
|
||||
Cache::put($this->hash, $report, 60 * 60);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +59,7 @@ class PreviewReport implements ShouldQueue
|
|||
public function failed(\Throwable $exception = null)
|
||||
{
|
||||
if($exception) {
|
||||
nlog("EXCEPTION:: PreviewReport:: could not preview report for" . $exception->getMessage());
|
||||
nlog("EXCEPTION:: PreviewReport:: could not preview report for " . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue