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