Example #1
0
 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;
 }
Example #2
0
 public function add_bwlist(Request $request)
 {
     if (Auth::check()) {
         if (in_array('ADD_EDIT_BWLIST', $this->permission)) {
             $validate = \Validator::make($request->all(), ['name' => 'required']);
             if ($validate->passes()) {
                 if (User::isSuperAdmin()) {
                     $advertiser_obj = Advertiser::with('GetClientID')->find($request->input('advertiser_id'));
                 } else {
                     $usr_company = $this->user_company();
                     $advertiser_obj = Advertiser::whereHas('GetClientID', function ($p) use($usr_company) {
                         $p->whereIn('user_id', $usr_company);
                     })->find($request->input('advertiser_id'));
                 }
                 if ($advertiser_obj) {
                     $chk = BWList::where('advertiser_id', $request->input('advertiser_id'))->get();
                     //                        return dd($chk);
                     $flg = 0;
                     foreach ($chk as $index) {
                         if ($index->name == $request->input('name') and $index->list_type == $request->input('list_type')) {
                             $flg = 1;
                         }
                     }
                     if ($flg == 0) {
                         $active = 'Inactive';
                         if ($request->input('active') == 'on') {
                             $active = 'Active';
                         }
                         $key = new AuditsController();
                         $key = $key->generateRandomString();
                         $audit = new AuditsController();
                         $bwlist = new BWList();
                         $bwlist->name = $request->input('name');
                         $bwlist->status = $active;
                         $bwlist->list_type = $request->input('list_type');
                         $bwlist->advertiser_id = $request->input('advertiser_id');
                         $bwlist->save();
                         $audit->store('bwlist', $bwlist->id, null, 'add', $key);
                         $entries = explode(',', $request->input('domain_name'));
                         foreach ($entries as $index) {
                             $bwlistentries = new BWEntries();
                             $bwlistentries->domain_name = $index;
                             $bwlistentries->bwlist_id = $bwlist->id;
                             $bwlistentries->save();
                             $audit->store('bwlistentrie', $bwlistentries->id, null, 'add', $key);
                         }
                         return Redirect::to(url('/client/cl' . $advertiser_obj->GetClientID->id . '/advertiser/adv' . $request->input('advertiser_id') . '/bwlist/bwl' . $bwlist->id . '/edit'))->withErrors(['success' => true, 'msg' => "B/W List added successfully"]);
                     }
                     return Redirect::back()->withErrors(['success' => false, 'msg' => 'this name already existed !!!'])->withInput();
                 }
                 return Redirect::back()->withErrors(['success' => false, 'msg' => 'please Select your Client'])->withInput();
             }
             return Redirect::back()->withErrors(['success' => false, 'msg' => $validate->messages()->all()])->withInput();
         }
         return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]);
     }
     return Redirect::to(url('/user/login'));
 }