public function show($id) { $guest = Guest::findOrFail($id); return view('guests.show', compact('guest')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id, Request $request) { $this->checkAdmin($request); Guest::findOrFail($id)->delete(); return ['id' => $id]; }
/** * Update the specified resource in storage. * * @param Request $request * @param App\Reservation $reservation * @return Response */ public function update(Request $request, Reservation $reservation) { $this->validate($request, ['name' => 'required', 'gender' => 'required', 'phone' => 'required|numeric', 'address' => 'required', 'check_in' => 'required|date|after:' . \Carbon\Carbon::today()->addDays(-1)->format('Y-m-d'), 'check_out' => 'required|date|after:' . $request->input('check_in')]); $input = $request->only('name', 'gender', 'phone', 'address'); if (Auth::user()->role != 'user') { $guest = Guest::findOrFail($reservation->guest_id); $guest->fill($input)->save(); $reservation_data = ['guest_id' => $guest->id, 'guest_type' => 'guest', 'check_in' => $request->input('check_in'), 'check_out' => $request->input('check_out')]; } else { $user = User::findOrFail(Auth::user()->id); $user->fill($input)->save(); $reservation_data = ['check_in' => $request->input('check_in'), 'check_out' => $request->input('check_out')]; } $reservation->fill($reservation_data)->save(); $roomTypes = $request->input('room_type_id'); $roomReserved = $request->input('total_room_reserved'); for ($i = 0; $i < count($roomTypes); $i++) { $reservation->roomTypes()->detach($roomTypes[$i]); $reservation->roomTypes()->attach($roomTypes[$i], ['total_room_reserved' => $roomReserved[$i]]); } return redirect('/reservation'); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update($id, Request $request) { $guest = Guest::findOrFail($id); $guest->update($request->all()); Session::flash('message', 'Guest Saved!'); return view('classmates.partial.detail', compact('guest')); }