public function index(Request $request) { if ($request->get('department')) { $services = \App\Service::filterByDepartment($request->get('department'))->get(); $departments = \App\Department::where('id', $request->get('department'))->get(); } elseif ($request->get('domain')) { $domain = \App\Domain::findOrfail($request->get('domain')); $services = $domain->services()->get(); $departments = $domain->departments()->get(); } else { $services = $this->services; $departments = \App\Department::all(); } return view('services.index', ['services' => $services, 'departments' => $departments]); }
/** * Treat this method as a controller action. * Return view() or other content to display. */ public function run() { return view("widgets.service_index", ['services' => Service::filterByDepartment($this->config['department'])->get()]); }