repository = $kategori; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Lilg\Poslilg\Repositories\Criteria\KategoriResourceCriteria::class); } /** * Display a list of kategori. * * @return Response */ public function index(KategoriRequest $request) { return $this->repository ->setPresenter(\Lilg\Poslilg\Repositories\Presenter\KategoriPresenter::class) ->paginate(); } /** * Display kategori. * * @param Request $request * @param Model $kategori * * @return Response */ public function show(KategoriRequest $request, Kategori $kategori) { return $kategori->setPresenter(\Lilg\Poslilg\Repositories\Presenter\KategoriListPresenter::class); ; } /** * Create new kategori. * * @param Request $request * * @return Response */ public function store(KategoriRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('poslilg::kategori.name')]); $code = 204; $status = 'success'; $url = guard_url('poslilg/kategori/' . $kategori->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('poslilg/kategori'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the kategori. * * @param Request $request * @param Model $kategori * * @return Response */ public function update(KategoriRequest $request, Kategori $kategori) { try { $data = $request->all(); $kategori->update($data); $message = trans('messages.success.updated', ['Module' => trans('poslilg::kategori.name')]); $code = 204; $status = 'success'; $url = guard_url('poslilg/kategori/' . $kategori->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('poslilg/kategori/' . $kategori->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the kategori. * * @param Model $kategori * * @return Response */ public function destroy(KategoriRequest $request, Kategori $kategori) { try { $kategori->delete(); $message = trans('messages.success.deleted', ['Module' => trans('poslilg::kategori.name')]); $code = 202; $status = 'success'; $url = guard_url('poslilg/kategori/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('poslilg/kategori/' . $kategori->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }