repository = $tabel_m; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Aldi\EPA\Repositories\Criteria\TabelMResourceCriteria::class); } /** * Display a list of tabel_m. * * @return Response */ public function index(TabelMRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Aldi\EPA\Repositories\Presenter\TabelMPresenter::class) ->$function(); } $tabel_ms = $this->repository->paginate(); return $this->response->title(trans('e_p_a::tabel_m.names')) ->view('e_p_a::tabel_m.index', true) ->data(compact('tabel_ms', 'view')) ->output(); } /** * Display tabel_m. * * @param Request $request * @param Model $tabel_m * * @return Response */ public function show(TabelMRequest $request, TabelM $tabel_m) { if ($tabel_m->exists) { $view = 'e_p_a::tabel_m.show'; } else { $view = 'e_p_a::tabel_m.new'; } return $this->response->title(trans('app.view') . ' ' . trans('e_p_a::tabel_m.name')) ->data(compact('tabel_m')) ->view($view, true) ->output(); } /** * Show the form for creating a new tabel_m. * * @param Request $request * * @return Response */ public function create(TabelMRequest $request) { $tabel_m = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('e_p_a::tabel_m.name')) ->view('e_p_a::tabel_m.create', true) ->data(compact('tabel_m')) ->output(); } /** * Create new tabel_m. * * @param Request $request * * @return Response */ public function store(TabelMRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $tabel_m = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('e_p_a::tabel_m.name')])) ->code(204) ->status('success') ->url(guard_url('e_p_a/tabel_m/' . $tabel_m->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/e_p_a/tabel_m')) ->redirect(); } } /** * Show tabel_m for editing. * * @param Request $request * @param Model $tabel_m * * @return Response */ public function edit(TabelMRequest $request, TabelM $tabel_m) { return $this->response->title(trans('app.edit') . ' ' . trans('e_p_a::tabel_m.name')) ->view('e_p_a::tabel_m.edit', true) ->data(compact('tabel_m')) ->output(); } /** * Update the tabel_m. * * @param Request $request * @param Model $tabel_m * * @return Response */ public function update(TabelMRequest $request, TabelM $tabel_m) { try { $attributes = $request->all(); $tabel_m->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('e_p_a::tabel_m.name')])) ->code(204) ->status('success') ->url(guard_url('e_p_a/tabel_m/' . $tabel_m->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('e_p_a/tabel_m/' . $tabel_m->getRouteKey())) ->redirect(); } } /** * Remove the tabel_m. * * @param Model $tabel_m * * @return Response */ public function destroy(TabelMRequest $request, TabelM $tabel_m) { try { $tabel_m->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('e_p_a::tabel_m.name')])) ->code(202) ->status('success') ->url(guard_url('e_p_a/tabel_m/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('e_p_a/tabel_m/' . $tabel_m->getRouteKey())) ->redirect(); } } /** * Remove multiple tabel_m. * * @param Model $tabel_m * * @return Response */ public function delete(TabelMRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('e_p_a::tabel_m.name')])) ->status("success") ->code(202) ->url(guard_url('e_p_a/tabel_m')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/e_p_a/tabel_m')) ->redirect(); } } /** * Restore deleted tabel_ms. * * @param Model $tabel_m * * @return Response */ public function restore(TabelMRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('e_p_a::tabel_m.name')])) ->status("success") ->code(202) ->url(guard_url('/e_p_a/tabel_m')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/e_p_a/tabel_m/')) ->redirect(); } } }