Hi im trying to access to my attribute username auth->user->username but it says that username doesnt exist while username is actually in my model and in my database. I created a mutator in my model User, but idoesnt retrieve the username. It actually works with email, name, id atributters but not with username. What can I do :C
<?php
namespace ILink;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name','username', 'email', 'password','profile_image'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function getUsernameAttribute()
{
return $this->username;
}
}
```
I solved it I don't know how but I create separate migrations for my custom values and now it works witout this
public function getUsernameAttribute()
{
return $this->username;
}