public function ChangeStatus($id) { if (Auth::check()) { if (in_array('ADD_EDIT_OFFER', $this->permission)) { if (User::isSuperAdmin()) { $entity = Offer::find($id); } else { $usr_company = $this->user_company(); $entity = Offer::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('offer', $id, $data, 'edit'); $entity->save(); return $msg; } } return "You don't have permission"; } return Redirect::to(url('user/login')); }
public function ModelEditView($clid, $advid, $mdlid) { if (!is_null($mdlid)) { if (Auth::check()) { if (in_array('ADD_EDIT_MODEL', $this->permission)) { if (User::isSuperAdmin()) { $offer = Offer::get(); $model_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($mdlid); } else { $usr_company = $this->user_company(); $model_obj = ModelTable::whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->find($mdlid); $offer = Offer::whereHas('getAdvertiser', function ($q) use($usr_company) { $q->whereHas('GetClientID', function ($p) use($usr_company) { $p->whereIn('user_id', $usr_company); }); })->get(); } if (!$model_obj) { return Redirect::back()->withErrors(['success' => false, 'msg' => 'please Select your Client'])->withInput(); } $positive_offer_id = array(); $negative_offer_id = array(); if (!is_null($model_obj->positive_offer_id)) { $positive_offer_id = explode(',', $model_obj->positive_offer_id); } if (!is_null($model_obj->negative_offer_id)) { $negative_offer_id = explode(',', $model_obj->negative_offer_id); } return view('model.edit')->with('offer_obj', $offer)->with('positive_offer_id', $positive_offer_id)->with('negative_offer_id', $negative_offer_id)->with('model_obj', $model_obj); } return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]); } return Redirect::to(url('/user/login')); } }