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