Custom relationship attributes
With Voyager 1.1 you are able to define additional attributes which you can show in a relationship.
For example a Post has an Author and you want to display the Users full-name. To do so, we first need to define an Accessor
1
public function getFullNameAttribute()
2
{
3
return "{$this->first_name} {$this->last_name}";
4
}
Copied!
After that we need to tell Voyager that there is an accessor we want to use:
1
public $additional_attributes = ['full_name'];
Copied!
Thats it! You can now select full_name in your Relationship.
Last modified 1mo ago
Export as PDF
Copy link