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