public function getCampaignSelect($adv_id) { if (Auth::check()) { if (in_array('VIEW_CAMPAIGN', $this->permission)) { if (User::isSuperAdmin()) { $next_child = Campaign::where('advertiser_id', $adv_id)->get(); } else { $usr_company = $this->user_company(); $next_child = Campaign::whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); })->where('advertiser_id', $adv_id)->get(); if (!$next_child) { return Redirect::back()->withErrors(['success' => false, 'msg' => 'please Select your Client'])->withInput(); } } return view('bulk.ajaxTask')->with('taskAjax', 'showCampaignSelect')->with('next_child', $next_child); } return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]); } }