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