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