/** * Get all components. * * @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Contracts\Auth\Guard $auth * * @return \Illuminate\Http\JsonResponse */ public function getComponents(Request $request, Guard $auth) { if ($auth->check()) { $components = Component::whereRaw('1 = 1'); } else { $components = Component::enabled(); } return $this->paginator($components->paginate(Binput::get('per_page', 20)), $request); }
/** * Get all components. * * @return \Illuminate\Http\JsonResponse */ public function getComponents() { if (app(Guard::class)->check()) { $components = Component::whereRaw('1 = 1'); } else { $components = Component::enabled(); } return $this->paginator($components->paginate(Binput::get('per_page', 20)), Request::instance()); }
/** * Get all components. * * @return \Illuminate\Http\JsonResponse */ public function getComponents() { if (app(Guard::class)->check()) { $components = Component::whereRaw('1 = 1'); } else { $components = Component::enabled(); } $components->search(Binput::except(['sort', 'order', 'per_page'])); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $components->sort($sortBy, $direction); } $components = $components->paginate(Binput::get('per_page', 20)); return $this->paginator($components, Request::instance()); }