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