*/ protected $fillable = [ 'name', 'phone', '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', 'password' => 'hashed', ]; public function getPartialsName() { $name = explode(' ', $this->name); return [ 'firstName' => (array_key_exists(0, $name) ? $name[0] : ''), 'secondName' => (array_key_exists(1, $name) ? $name[1] : ''), 'familyName' => (array_key_exists(2, $name) ? $name[2] : '') ]; } public function roles(): HasManyThrough { return $this->hasManyThrough( Role::class , UserRole::class , 'user_id' , 'id' , 'id' , 'role_id' ); } }