repository = $master_settings; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\B2buy\MasterSetting\Repositories\Criteria\MasterSettingsResourceCriteria::class); } /** * Display a list of master_settings. * * @return Response */ public function index(MasterSettingsRequest $request) { return $this->repository ->setPresenter(\B2buy\MasterSetting\Repositories\Presenter\MasterSettingsPresenter::class) ->paginate(); } /** * Display master_settings. * * @param Request $request * @param Model $master_settings * * @return Response */ public function show(MasterSettingsRequest $request, MasterSettings $master_settings) { return $master_settings->setPresenter(\B2buy\MasterSetting\Repositories\Presenter\MasterSettingsListPresenter::class); ; } /** * Create new master_settings. * * @param Request $request * * @return Response */ public function store(MasterSettingsRequest $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('master_setting::master_settings.name')]); $code = 204; $status = 'success'; $url = guard_url('master_setting/master_settings/' . $master_settings->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('master_setting/master_settings'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the master_settings. * * @param Request $request * @param Model $master_settings * * @return Response */ public function update(MasterSettingsRequest $request, MasterSettings $master_settings) { try { $data = $request->all(); $master_settings->update($data); $message = trans('messages.success.updated', ['Module' => trans('master_setting::master_settings.name')]); $code = 204; $status = 'success'; $url = guard_url('master_setting/master_settings/' . $master_settings->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('master_setting/master_settings/' . $master_settings->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the master_settings. * * @param Model $master_settings * * @return Response */ public function destroy(MasterSettingsRequest $request, MasterSettings $master_settings) { try { $master_settings->delete(); $message = trans('messages.success.deleted', ['Module' => trans('master_setting::master_settings.name')]); $code = 202; $status = 'success'; $url = guard_url('master_setting/master_settings/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('master_setting/master_settings/' . $master_settings->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); } }