model = $trips; $this->model->setUserFilter(); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(TripsUserRequest $request) { $trips = $this->model->all(); $this->theme->prependTitle(trans('trip::trips.names').' :: '); return $this->theme->of('trip::user.trips.index', compact('trips'))->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(TripsUserRequest $request, $role, $id) { $trips = $this->model->find($id); return $this->theme->of('trip::user.trips.show', compact('trips'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(TripsUserRequest $request) { $trips = $this->model->findOrNew(0); Former::populate($trips); return $this->theme->of('trip::user.trips.create', compact('trips'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(TripsUserRequest $request) { try { $attributes = $request->all(); $trips = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('trip::trips.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function edit(TripsUserRequest $request, $role, $id) { $trips = $this->model->find($id); Former::populate($trips); return $this->theme->of('trip::user.trips.edit', compact('trips'))->render(); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(TripsUserRequest $request, $role, $id) { try { $attributes = $request->all(); $trips = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('trip::trips.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(TripsUserRequest $request, $role, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('trip::trips.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }