added customer scopes to user model
This commit is contained in:
		| @@ -182,7 +182,7 @@ class User extends Authenticatable implements HasLocalePreference | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Scope to only include active currencies. | ||||
|      * Scope to only include active users. | ||||
|      * | ||||
|      * @param \Illuminate\Database\Eloquent\Builder $query | ||||
|      * @return \Illuminate\Database\Eloquent\Builder | ||||
| @@ -192,6 +192,28 @@ class User extends Authenticatable implements HasLocalePreference | ||||
|         return $query->where('enabled', 1); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Scope to only customers. | ||||
|      * | ||||
|      * @param \Illuminate\Database\Eloquent\Builder $query | ||||
|      * @return \Illuminate\Database\Eloquent\Builder | ||||
|      */ | ||||
|     public function scopeIsCustomer($query) | ||||
|     { | ||||
|         return $query->wherePermissionIs('read-client-portal'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Scope to only users. | ||||
|      * | ||||
|      * @param \Illuminate\Database\Eloquent\Builder $query | ||||
|      * @return \Illuminate\Database\Eloquent\Builder | ||||
|      */ | ||||
|     public function scopeIsNotCustomer($query) | ||||
|     { | ||||
|         return $query->wherePermissionIs('read-admin-panel'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Attach company_ids attribute to model. | ||||
|      * | ||||
| @@ -216,6 +238,26 @@ class User extends Authenticatable implements HasLocalePreference | ||||
|         $this->offsetUnset('company_ids'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Determine if user is a customer. | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function isCustomer() | ||||
|     { | ||||
|         return (bool) $this->can('read-client-portal'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Determine if user is not a customer. | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function isNotCustomer() | ||||
|     { | ||||
|         return (bool) $this->can('read-admin-panel'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the user's preferred locale. | ||||
|      * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user