%PDF- %PDF-
Direktori : /home/silvzytp/crm-ind-code/app/Models/ |
Current File : /home/silvzytp/crm-ind-code/app/Models/User.php |
<?php namespace App\Models; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'role_id', 'admin_id', 'name', 'email', 'password', 'password_text', 'avatar', 'note', 'manager_id', 'phone_no', 'country_code', 'status' ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function role(){ return $this->belongsTo(Role::class); } public function manager(){ return $this->belongsTo(User::class, 'manager_id','id'); } public function agents(){ return $this->hasMany(User::class, 'manager_id','id'); } public function hasPermission($permission): bool { return $this->role->permissions->where('slug',$permission)->first() ? true : false; } public function callings(){ return $this->hasMany(Colling::class, 'agent_id','id'); } }