Voyager RU
  • Вступление
  • С чего начать
    • Что такое Voyager
    • Требования
    • Установка
    • Upgrading
    • Конфигурации
  • BREAD
    • Введение
    • Отношения
    • Поля форм
      • Флажки (Checkbox)
      • Координаты
      • Дата и время
      • Выпадающий список (Dropdown)
      • Изображения
      • Загрузка файлов (Media Picker)
      • Ввод чисел (Number)
      • TinyMCE
  • Основные концепции
    • Маршрутизация
    • Медиа-менеджер
    • Меню и конструктор меню
    • Управление базой данных
    • Настройки
    • Навигатор (Compass)
    • Роли и разрешения
    • Helper methods
    • Многоязычность
  • Персонализация
    • Переопределение файлов
    • Переопределение маршрутов
    • 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

Was this helpful?

  1. Персонализация

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 4 years ago

Was this helpful?