Voyager
HomeGithubIssues
1.4
1.4
  • Introduction
  • Getting started
    • What is Voyager
    • Prerequisites
    • Installation
    • Upgrading
    • Configurations
  • BREAD
    • Introduction
    • Relationships
    • Formfields
      • Checkbox/Multiple Checkbox/Radio
      • Coordinates
      • Date & Time
      • Dropdown
      • Images
      • Media Picker
      • Number
      • TinyMCE
  • Core concepts
    • Routing
    • Media Manager
    • Menus and Menu Builder
    • Database Manager
    • Settings
    • Compass
    • Roles and Permissions
    • Helper methods
    • Multilanguage
  • Customization
    • Overriding files
    • Overriding Routes
    • Additional CSS and JS
    • Enabling Soft-Delete
    • Custom relationship attributes
    • Adding custom Formfields
    • Coordinates
    • BREAD accessors
    • Custom guard
    • Action buttons
  • Troubleshooting
    • Using HTTPS on yours site
    • Missing required parameter
Powered by GitBook
On this page
Export as PDF
  1. Customization

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

public function getFullNameAttribute()
{
    return "{$this->first_name} {$this->last_name}";
}

After that we need to tell Voyager that there is an accessor we want to use:

public $additional_attributes = ['full_name'];

Thats it! You can now select full_name in your Relationship.

PreviousEnabling Soft-DeleteNextAdding custom Formfields

Last updated 5 years ago