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