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