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