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