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