$accesses * @property-read int|null $accesses_count * @property-read \Illuminate\Database\Eloquent\Collection $products * @property-read int|null $products_count * @property-read \Illuminate\Database\Eloquent\Collection $accesses * @property-read \Illuminate\Database\Eloquent\Collection $products * @property-read \Illuminate\Database\Eloquent\Collection $accesses * @property-read \Illuminate\Database\Eloquent\Collection $products * @mixin \Eloquent */ class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable,StarterKit; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', ]; /** * 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', ]; public function posts(){ return $this->hasMany(Post::class); } public function products(){ return $this->hasMany(Product::class); } public function accesses(){ return $this->hasMany(Access::class); } public function hasAnyAccess($name){ if ($this->hasRole('super-admin')){ return true; } return $this->accesses()->where('route','LIKE','%.'.$name.'.%')->count() > 0; } public function hasAccess($route){ return $this->accesses()->where('route',$route)->count() > 0; } }