hasMany(ManageModuleLink::class,'principal_xid', 'id'); } public function feedbacks() { return $this->hasMany(ManageFeedback::class, 'principal_xid', 'id'); } public function getresturant() { return $this->hasMany(IamPrincipalRestaurantRole::class, 'principal_xid', 'id'); } public function getCustomerCount() { // Fetch the count of customers $customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count(); return $customerCount; } // protected $fillable = // [ // 'principal_type_xid', // 'principal_source_xid', // 'user_name', // 'password_hash', // 'pin', // 'first_name', // 'last_name', // 'gender', // 'date_of_birth', // 'phone_number', // 'other_phone_number', // 'email_address', // 'address_line1', // 'address_line2', // 'city_xid', // 'state_xid', // 'country_xid', // 'post_code', // 'last_login_datetime', // 'profile_photo', // 'referral_code', // 'description', // 'is_active' // ]; public function getJWTIdentifier() { return $this->getKey(); } public function getJWTCustomClaims() { return []; } /** * The attributes that are mass assignable. * * @var array */ /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; public function getPermissionGranted($id,$module) { // $id is used as authuser id // $moudle is the slug of sidebar module $isSubAdmin = IamPrincipal::where('id',$id)->where('principal_type_xid',2)->first(); // 'is_admin',1 is for checking the login user is subadmin or not $isMainAdmin = IamPrincipal::where('id',$id)->where('principal_type_xid',1)->first(); if($isMainAdmin){ return true; }elseif($isSubAdmin){ //search for module $isModule = ManageModule::where('slug',$module)->first(); if($isModule){ $isSubAdminModuleLink = ManageModuleLink::where('principal_xid',$id) ->where('manage_modules_xid',$isModule->id)->first(); // dd($id,$module,$isSubAdmin->id,$isModule,$isSubAdminModuleLink); if($isSubAdminModuleLink){ return true; }else{ return false; } }else{ return false; } }else{ return false; } } public function orders() { return $this->hasMany(OrderedPassport::class, 'iam_principal_xid','id'); } public function notification() { return $this->hasMany(NotificationDetails::class,'principal_xid', 'id'); } }