I am having issues with laravel 4 that did not happen with 3.
In the Permissions_Role model I have this relationship set up.
/**
* User Relationship
*
* @return User
*/
public function user()
{
return $this->belongsTo('User', 'user_id');
}
Now, I want to use it later in the model to get that user's username. In laravel 3 this could be done with the following.
return ucword($this->user()->first()->username);
However, in four, it does not seem to return an object the same way and I can't seem to figure out the new syntax for it. Below is what I am trying currently.
/**
* Get username
*
* @return string
*/
public function getUsernameAttribute()
{
return ucwords($this->user()->first()->username);
}
Any help on this would be greatly appreciated. Thanks :)