repository = $mark; $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->pushCriteria(new \Asadi\Mark\Repositories\Criteria\MarkUserCriteria()); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(MarkRequest $request) { $marks = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('mark::mark.names')); return $this->theme->of('mark::user.mark.index', compact('marks'))->render(); } /** * Display the specified resource. * * @param Request $request * @param Mark $mark * * @return Response */ public function show(MarkRequest $request, Mark $mark) { Form::populate($mark); return $this->theme->of('mark::user.mark.show', compact('mark'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(MarkRequest $request) { $mark = $this->repository->newInstance([]); Form::populate($mark); $this->theme->prependTitle(trans('mark::mark.names')); return $this->theme->of('mark::user.mark.create', compact('mark'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(MarkRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $mark = $this->repository->create($attributes); return redirect(trans_url('/user/mark/mark')) -> with('message', trans('messages.success.created', ['Module' => trans('mark::mark.name')])) -> with('code', 201); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param Mark $mark * * @return Response */ public function edit(MarkRequest $request, Mark $mark) { Form::populate($mark); $this->theme->prependTitle(trans('mark::mark.names')); return $this->theme->of('mark::user.mark.edit', compact('mark'))->render(); } /** * Update the specified resource. * * @param Request $request * @param Mark $mark * * @return Response */ public function update(MarkRequest $request, Mark $mark) { try { $this->repository->update($request->all(), $mark->getRouteKey()); return redirect(trans_url('/user/mark/mark')) ->with('message', trans('messages.success.updated', ['Module' => trans('mark::mark.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(MarkRequest $request, Mark $mark) { try { $this->repository->delete($mark->getRouteKey()); return redirect(trans_url('/user/mark/mark')) ->with('message', trans('messages.success.deleted', ['Module' => trans('mark::mark.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }