/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request, $project_id) { $project_parts = Project_part::where('project_id', $project_id)->orderBy('priority')->get(); if ($request->ajax()) { return $project_parts->toArray(); } return view('admin.project_parts.index', ['project_parts' => $project_parts]); }