form = FacebookCampaignsForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('restaurant.facebook.modules'), 'facebook', guard_url('facebook')); } /** * Display a list of facebook_campaigns. * * @return Response */ public function index(FacebookCampaignsRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $page = FacebookCampaigns::pushScope(new RequestScope()) ->pushScope(new FacebookCampaignsResourceScope()) ->simplePaginate($pageLimit); $data = new FacebookCampaignsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('facebook::facebook_campaigns.names')) ->view('facebook::facebook_campaigns.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display facebook_campaigns. * * @param Request $request * @param Model $facebook_campaigns * * @return Response */ public function show(FacebookCampaignsRequest $request, FacebookCampaigns $model) { $form = $this->form; $modules = $this->modules; $data = new FacebookCampaignsResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('facebook::facebook_campaigns.name')) ->data(compact('data', 'form', 'modules')) ->view('facebook::facebook_campaigns.show') ->output(); } /** * Show the form for creating a new facebook_campaigns. * * @param Request $request * * @return Response */ public function create(FacebookCampaignsRequest $request, FacebookCampaigns $model) { $form = $this->form; $modules = $this->modules; $data = new FacebookCampaignsResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('facebook::facebook_campaigns.name')) ->view('facebook::facebook_campaigns.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new facebook_campaigns. * * @param Request $request * * @return Response */ public function store(FacebookCampaignsRequest $request, FacebookCampaigns $model) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $model = $model->create($attributes); $data = new FacebookCampaignsResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('facebook::facebook_campaigns.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('facebook/facebook_campaigns/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/facebook/facebook_campaigns')) ->redirect(); } } /** * Show facebook_campaigns for editing. * * @param Request $request * @param Model $facebook_campaigns * * @return Response */ public function edit(FacebookCampaignsRequest $request, FacebookCampaigns $model) { $form = $this->form; $modules = $this->modules; $data = new FacebookCampaignsResource($model); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('facebook::facebook_campaigns.name')) ->view('facebook::facebook_campaigns.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the facebook_campaigns. * * @param Request $request * @param Model $facebook_campaigns * * @return Response */ public function update(FacebookCampaignsRequest $request, FacebookCampaigns $model) { try { $attributes = $request->all(); $model = $model->update($attributes); $data = new FacebookCampaignsResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('facebook::facebook_campaigns.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('facebook/facebook_campaigns/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('facebook/facebook_campaigns/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the facebook_campaigns. * * @param Model $facebook_campaigns * * @return Response */ public function destroy(FacebookCampaignsRequest $request, FacebookCampaigns $model) { try { $model->delete(); $data = new FacebookCampaignsResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('facebook::facebook_campaigns.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('facebook/facebook_campaigns/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('facebook/facebook_campaigns/' . $model->getRouteKey())) ->redirect(); } } }