php Laravel API简单过滤器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Laravel API简单过滤器相关的知识,希望对你有一定的参考价值。
public function index(Request $request)
{
$applications = $this->application->query();
if ($request->filled('codes')) {
$application_codes = $request->codes;
$application_codes = explode(',',$application_codes);
$applications->whereIn('code', $application_codes);
}
if ($request->has('all')) {
$applications = $applications->get();
}
else {
$limit = $request->query('limit', 50);
$applications = $applications->paginate($limit);
}
return new ApplicationResourceCollection($applications->appends($request->except('page')));
}
以上是关于php Laravel API简单过滤器的主要内容,如果未能解决你的问题,请参考以下文章