Exemplo n.º 1
0
 /**
  * @param User $user
  *
  * @return array
  */
 protected function data(User $user)
 {
     $this->getInstance();
     $this->user = $user;
     $this->profile = $this->user->profile()->first();
     $this->retailer = $this->user->retailerUser->retailer;
     $this->getDataForReport();
     return ['cities' => $this->cities, 'agencies' => $this->agencies, 'users' => $this->users];
 }
Exemplo n.º 2
0
 public function __construct(PdfController $pdf)
 {
     $this->pdf = $pdf;
     $auth = Auth::user();
     $user = User::where('id', $auth->id)->first();
     $this->retailer = $user->retailerUser->retailer;
 }
Exemplo n.º 3
0
 public function __construct(PdfController $pdf)
 {
     $this->pdf = $pdf;
     $auth = Auth::user();
     $user = User::where('id', $auth->id)->first();
     $this->retailer = $user->retailerUser->retailer;
     $this->retailerProduct = RetailerProduct::where('ad_retailer_id', $this->retailer->id)->where('type', 'MP')->get();
 }
Exemplo n.º 4
0
 public function listUser($auth)
 {
     if ($auth == 'ADT') {
         $this->model = User::join('ad_user_types', 'ad_users.ad_user_type_id', '=', 'ad_user_types.id')->leftjoin('ad_cities', 'ad_users.ad_city_id', '=', 'ad_cities.id')->leftjoin('ad_agencies', 'ad_users.ad_agency_id', '=', 'ad_agencies.id')->leftjoin('ad_user_profiles as aup', 'aup.ad_user_id', '=', 'ad_users.id')->leftjoin('ad_retailer_users', 'ad_retailer_users.ad_user_id', '=', 'ad_users.id')->leftjoin('ad_profiles as ap', 'ap.id', '=', 'aup.ad_profile_id')->select('ad_users.id as id_user', 'ad_user_types.name as type', 'ad_users.username', 'ad_users.full_name', 'ad_users.email', 'ad_cities.name as cities', 'ad_agencies.name as agencies', 'ad_users.active', 'ap.name as profile', 'aup.active as active_profile', 'ad_retailer_users.ad_retailer_id', 'ad_user_types.code as code_type')->where('ad_user_types.code', '<>', 'ADT')->get();
     } else {
         $this->model = User::join('ad_user_types', 'ad_users.ad_user_type_id', '=', 'ad_user_types.id')->leftjoin('ad_cities', 'ad_users.ad_city_id', '=', 'ad_cities.id')->leftjoin('ad_agencies', 'ad_users.ad_agency_id', '=', 'ad_agencies.id')->leftjoin('ad_user_profiles as aup', 'aup.ad_user_id', '=', 'ad_users.id')->leftjoin('ad_retailer_users', 'ad_retailer_users.ad_user_id', '=', 'ad_users.id')->leftjoin('ad_profiles as ap', 'ap.id', '=', 'aup.ad_profile_id')->select('ad_users.id as id_user', 'ad_user_types.name as type', 'ad_users.username', 'ad_users.full_name', 'ad_users.email', 'ad_cities.name as cities', 'ad_agencies.name as agencies', 'ad_users.active', 'ap.name as profile', 'aup.active as active_profile', 'ad_retailer_users.ad_retailer_id', 'ad_user_types.code as code_type')->where('ad_user_types.code', '<>', 'ADT')->where('ad_user_types.code', '<>', 'OPT')->get();
     }
     if ($this->model->count() > 0) {
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * @param int $retailer_id
  *
  * @return mixed
  */
 public function getUsersByRetailer($retailer_id)
 {
     return User::with('agency', 'city')->whereHas('retailerUser.retailer', function ($q) use($retailer_id) {
         $q->where('ad_retailers.id', $retailer_id);
     })->where('username', '!=', 'admin')->get();
 }
Exemplo n.º 6
0
 public function ajax_active_inactive($id_user, $text)
 {
     if ($text == 'inactive') {
         $user_update = User::find($id_user);
         $user_update->active = false;
         if ($user_update->save()) {
             return 1;
         } else {
             return 0;
         }
     } elseif ($text == 'active') {
         $user_update = User::find($id_user);
         $user_update->active = true;
         if ($user_update->save()) {
             return 1;
         } else {
             return 0;
         }
     }
 }