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