/** * Determine if the user is authorized to make this request. * * @param Request $request * @return bool */ public function authorize(Request $request) { $landing_page_id = $request->get('landing_page_id'); $landing_page = Landing_Page::findOrFail($landing_page_id); // Check that user is part of campaign users return $landing_page->first()->campaign->users->contains(Auth::id()) ? true : false; }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { // URL route is implicitly defined as the resource $landing_page_id = $this->route('landing_pages'); $landing_page = Landing_Page::findOrFail($landing_page_id); // Check that user is part of campaign users return $landing_page->first()->campaign->users->contains(Auth::id()) ? true : false; }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { // URL route is implicitly defined as the resource $landing_page_id = $this->route('landing_pages'); $campaign_id = Landing_Page::findOrFail($landing_page_id)->first()->campaign->id; return Campaign::where('id', $campaign_id)->with('users')->whereHas('users', function ($q) { $q->where('user_id', Auth::id())->where('role_id', config('roles.admin')); })->exists(); }
/** * Determine if the user is authorized to make this request. * * @param Request $request * @return bool */ public function authorize(Request $request) { /** * This request is publicly accessible */ $landing_page_id = $request->get('landing_page_id'); $landing_page = Landing_Page::findOrFail($landing_page_id); // Check that landing page and campaign are both active return $landing_page->active == 1 && $landing_page->campaign->active ? true : false; }