/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //$client = Client::findOrFail($id); //return view('clients.show')->withClient($client); $client = Client::with('Tasks', 'Tasks.taskAssignedTo')->findOrFail($id); return view('clients.show')->with(compact('client')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { return view('project.index', ['clients' => Client::with(['projects' => function ($query) { $query->select(['*', DB::raw('closed_at IS NULL AS open')]); $query->orderBy('open', 'desc')->orderBy('closed_at', 'desc')->orderBy('closed_at', 'desc'); }])->orderBy('name')->get()]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { if (!($client = Client::with(['projects' => function ($query) { $query->select(['*', DB::raw('closed_at IS NULL AS open')]); $query->orderBy('open', 'desc')->orderBy('closed_at', 'desc')->orderBy('closed_at', 'desc'); }])->find($id))) { return redirect()->action('ClientController@index'); } return view('client.show', compact('client')); }
/** * client rental histories * @param $id * @return \Illuminate\Http\JsonResponse */ public function histories($id) { $histories = Client::with(['histories' => function ($query) { $query->join('car', 'car.id', '=', 'rental.car-id')->select('client-id', 'brand', 'type', 'plate', 'date-from', 'date-to'); }])->find($id); if ($histories == null) { $histories = ['error' => 'Client data not found']; } return response()->json($histories); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return Client::with(['images', 'attributes'])->find($id); }