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