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