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