For example un User model we have that code:
/**
* The attributes that should be visible in arrays.
*
* @var array
*/
protected $visible = [
'id',
'username',
'verified'
];
public function getVerifiedAttribute($value = null)
{
return $this->email_verified_at !== null;
}
in that case (string) request()->user() will show only id/username in json array, verified is not exists and we manually created it.
@n0n0n0n0 you should use protected $appends = ['verified'];
Most helpful comment
@n0n0n0n0 you should use
protected $appends = ['verified'];