public function creative_bulk(Request $request) { // return dd($request->all()); if (Auth::check()) { if (in_array('ADD_EDIT_CREATIVE', $this->permission)) { $validate = $this->validation($request); if ($validate->passes()) { $usr_company = $this->user_company(); $audit = new AuditsController(); $audit_key = $audit->generateRandomString(); if ($request->input('advertiser_id') == 'all' and !$request->has('creative_list')) { if ($request->input('client_id') == 'all') { if (User::isSuperAdmin()) { $creative_list = Creative::get(['id'])->toArray(); } else { $creative_list = Creative::whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->get(['id'])->toArray(); } } elseif ($request->input('client_id') != 'all') { if (User::isSuperAdmin()) { $creative_list = Creative::whereHas('getAdvertiser', function ($q) use($request) { $q->where('client_id', $request->input('client_id')); })->get(['id'])->toArray(); } else { //////////////////////// $creative_list = Creative::whereHas('getAdvertiser', function ($q) use($usr_company, $request) { $q->whereHas('GetClientID', function ($p) use($usr_company, $request) { $p->where('id', $request->input('client_id'))->whereIn('user_id', $usr_company); }); })->get(['id'])->toArray(); } } } elseif ($request->input('advertiser_id') != 'all' and !$request->has('creative_list')) { if (User::isSuperAdmin()) { $creative_list = Creative::whereHas('getAdvertiser', function ($q) use($request) { $q->where('id', $request->input('advertiser_id')); })->get(['id'])->toArray(); } else { //////////////////////// $creative_list = Creative::whereHas('getAdvertiser', function ($q) use($usr_company, $request) { $q->where('id', $request->input('advertiser_id'))->whereHas('GetClientID', function ($p) use($usr_company, $request) { $p->whereIn('user_id', $usr_company); }); })->get(['id'])->toArray(); } } else { $creative_list = explode(',', $request->input('creative_list')); } if (count($creative_list) > 0) { foreach ($creative_list as $index) { $data = array(); if (!$request->has('creative_list')) { $creative_id = $index['id']; $creative = Creative::find($creative_id); } else { $creative_id = $index; if (User::isSuperAdmin()) { $creative = Creative::find($creative_id); } else { $usr_company = $this->user_company(); $creative = Creative::whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->find($creative_id); } } if ($creative) { if ($request->has('size_width') and $request->has('size_height')) { $size = $request->input('size_width') . 'x' . $request->input('size_height'); } if ($request->input('name')) { array_push($data, 'Name'); array_push($data, $request->input('name')); $creative->name = $request->input('name'); } if ($request->has('active')) { $active = 'Inactive'; if ($request->input('active') == 'on') { $active = 'Active'; } array_push($data, 'Status'); array_push($data, $active); $creative->status = $active; } if ($request->input('ad_type')) { array_push($data, 'Ad Type'); array_push($data, $request->input('ad_type')); $creative->ad_type = $request->input('ad_type'); } if ($request->has('api')) { array_push($data, 'API'); array_push($data, json_encode($request->input('api'))); $creative->api = json_encode($request->input('api')); } if ($request->input('advertiser_domain_name')) { array_push($data, 'Domain Name'); array_push($data, $request->input('advertiser_domain_name')); $creative->advertiser_domain_name = $request->input('advertiser_domain_name'); } if ($request->input('description')) { array_push($data, 'Description'); array_push($data, $request->input('description')); $creative->description = $request->input('description'); } if ($request->input('landing_page_url')) { array_push($data, 'Landing Page URL'); array_push($data, $request->input('landing_page_url')); $creative->landing_page_url = $request->input('landing_page_url'); } if ($request->input('preview_url')) { array_push($data, 'Preview URL'); array_push($data, $request->input('preview_url')); $creative->preview_url = $request->input('preview_url'); } if ($request->input('attributes')) { array_push($data, 'Attributes'); array_push($data, $request->input('attributes')); $creative->attributes = $request->input('attributes'); } if ($request->input('ad_tag')) { array_push($data, 'AD Tag'); array_push($data, $request->input('ad_tag')); $creative->ad_tag = $request->input('ad_tag'); } if (isset($size)) { array_push($data, 'Size'); array_push($data, $size); $creative->size = $size; } $audit->store('creative', $creative_id, $data, 'bulk_edit', $audit_key); $creative->save(); } } return Redirect::back()->withErrors(['success' => true, 'msg' => 'Creatives Edited Successfully']); } } return Redirect::back()->withErrors(['success' => false, 'msg' => $validate->messages()->all()])->withInput(); } return Redirect::back()->withErrors(['success' => false, 'msg' => 'dont have Edit Permission']); } return Redirect::to(url('/user/login')); }
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 ChangeStatus($id) { if (Auth::check()) { if (in_array('ADD_EDIT_CREATIVE', $this->permission)) { if (User::isSuperAdmin()) { $entity = Creative::find($id); } else { $usr_company = $this->user_company(); $entity = Creative::whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->find($id); if (!$entity) { return 'please Select your Client'; } } if ($entity) { $data = array(); $audit = new AuditsController(); if ($entity->status == 'Active') { array_push($data, 'status'); array_push($data, $entity->status); array_push($data, 'Inactive'); $entity->status = 'Inactive'; $msg = 'disable'; } elseif ($entity->status == 'Inactive') { array_push($data, 'status'); array_push($data, $entity->status); array_push($data, 'Active'); $entity->status = 'Active'; $msg = 'actived'; } $audit->store('creative', $id, $data, 'edit'); $entity->save(); return $msg; } } return "You don't have permission"; } return Redirect::to(url('user/login')); }