public function SubAudit($audit) { $audit_obj = array(); foreach ($audit as $index) { $entity_obj = null; switch ($index->entity_type) { case 'user': if (in_array('VIEW_USER', $this->permission)) { $entity_obj = User::find($index->entity_id); } break; case 'company': if (User::isSuperAdmin()) { $entity_obj = \App\Models\Company::find($index->entity_id); } break; case 'inventory': if (User::isSuperAdmin()) { $entity_obj = Inventory::find($index->entity_id); } break; case 'client': if (in_array('VIEW_CLIENT', $this->permission)) { $entity_obj = Client::find($index->entity_id); } break; case 'advertiser': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = Advertiser::with('GetClientID')->find($index->entity_id); } break; case 'creative': if (in_array('VIEW_CREATIVE', $this->permission)) { $entity_obj = Creative::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'campaign': if (in_array('VIEW_CAMPAIGN', $this->permission)) { $entity_obj = Campaign::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'offer': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'pixel': if (in_array('VIEW_PIXEL', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'targetgroup': if (in_array('VIEW_TARGETGROUP', $this->permission)) { $entity_obj = Targetgroup::find($index->entity_id); } break; case 'targetgroup_geolocation_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Geolocation::find($index->after_value); } else { $entity_obj = Geolocation::find($index->entity_id); } } break; case 'targetgroup_creative_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Creative::find($index->after_value); } else { $entity_obj = Creative::find($index->entity_id); } } break; case 'targetgroup_segment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Segment::find($index->after_value); } else { $entity_obj = Segment::find($index->entity_id); } } break; case 'targetgroup_geosegment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegmentList::find($index->after_value); } else { $entity_obj = GeoSegmentList::find($index->entity_id); } } break; case 'targetgroup_bwlist_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::find($index->after_value); } else { $entity_obj = BWList::find($index->entity_id); } } break; case 'targetgroup_bidprofile_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::find($index->after_value); } else { $entity_obj = Bid_Profile::find($index->entity_id); } } break; case 'geosegment': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { $entity_obj = GeoSegmentList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'geosegmententrie': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegment::find($index->after_value); } else { $entity_obj = GeoSegment::find($index->entity_id); } } break; case 'bwlist': if (in_array('VIEW_BWLIST', $this->permission)) { $entity_obj = BWList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bwlistentrie': if (in_array('VIEW_BWLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWEntries::find($index->after_value); } else { $entity_obj = BWEntries::find($index->entity_id); } } break; case 'bid_profile': if (in_array('VIEW_BIDPROFILE', $this->permission)) { $entity_obj = Bid_Profile::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bid_profile_entry': if (in_array('VIEW_BIDPROFILE', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::where('id', $index->after_value)->first(); } else { $entity_obj = Bid_Profile_Entry::with('getParent')->find($index->entity_id); } } break; case 'modelTable': if (in_array('VIEW_MODEL', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::where('id', $index->after_value)->first(); } else { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } } break; case 'offer_pixel_map': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'advertiser_model_map': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'positive_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'negative_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; } if (!is_null($entity_obj)) { array_push($audit_obj, $index); array_push($audit_obj, $entity_obj); } } return $audit_obj; }
public function AdvertiserEditView($clid, $advid) { if (!is_null($advid)) { if (Auth::check()) { if (in_array('ADD_EDIT_ADVERTISER', $this->permission)) { if (User::isSuperAdmin()) { $adver = Advertiser::with('Campaign', 'Model', 'GeoSegment', 'BWList', 'Creative', 'GetClientID', 'Segment', 'BidProfile')->find($advid); $model_obj = ModelTable::where('advertiser_id', $advid)->with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->get(); } else { $usr_company = $this->user_company(); $model_obj = ModelTable::where('advertiser_id', $advid)->whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->get(); $adver = Advertiser::whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); })->with('Campaign', 'Model', 'GeoSegment', 'BWList', 'Creative', 'GetClientID', 'Segment', 'BidProfile')->find($advid); } if (!$adver) { return Redirect::back()->withErrors(['success' => false, 'msg' => 'please Select your Client'])->withInput(); } $push_arr = array(); $adv_mdl_map = Advertiser_Model_Map::where('advertiser_id', $adver->id)->get(['model_id']); if ($adv_mdl_map) { foreach ($adv_mdl_map as $index) { array_push($push_arr, $index->model_id); } } return view('advertiser.edit_advertiser')->with('adv_mdl_map', $push_arr)->with('model_obj', $model_obj)->with('adver_obj', $adver); } return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]); } return Redirect::to(url('user/login')); } }
public function jqgrid(Request $request) { // return dd($request->all()); if (Auth::check()) { if (in_array('ADD_EDIT_MODEL', $this->permission)) { $validate = \Validator::make($request->all(), ['name' => 'required']); if ($validate->passes()) { $model_id = substr($request->input('id'), 3); if (User::isSuperAdmin()) { $modelTable = ModelTable::find($model_id); } else { $usr_company = $this->user_company(); $modelTable = ModelTable::whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->find($model_id); } if ($modelTable) { $data = array(); $audit = new AuditsController(); if ($modelTable->name != $request->input('name')) { array_push($data, 'Name'); array_push($data, $modelTable->name); array_push($data, $request->input('name')); $modelTable->name = $request->input('name'); } $audit->store('modelTable', $model_id, $data, 'edit'); $modelTable->save(); return $msg = ['success' => true, 'msg' => "your Model Saved successfully"]; } return $msg = ['success' => false, 'msg' => "Please Select a Model First"]; } return $msg = ['success' => false, 'msg' => "Please Check your field"]; } return $msg = ['success' => false, 'msg' => "You don't have permission"]; } return Redirect::to(url('/user/login')); }