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

BREAD accessors

Sometimes you want to format an attribute only for one (or some) of the BREAD-actions. For example if you have a name field and on the browse-page you want to display something when the field is empty, you define the following in your model:

<?php

public function getNameBrowseAttribute()
{
    return $this->name ?? 'Empty';
}

This will display "Empty" if the actual field is empty, or return the value if not.

Likewise you can do the same for the other BREAD-actions:

<?php

public function getNameReadAttribute()
{
    //
}

public function getNameEditAttribute()
{
    //
}

public function getNameAddAttribute()
{
    //
}
PreviousCoordinatesNextCustom guard

Last updated 5 years ago