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