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. Персонализация

Coordinates

PreviousAdding custom FormfieldsNextBREAD accessors

Last updated 4 years ago

Was this helpful?

With Voyager you are able to store coordinates and select them from a map. To do so, you first need to make sure that the column in your table is either GEOMETRY or POINT.

After that you have to include the Spatial-Trait in your Model and define the column:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Traits\Spatial;

class Category extends Model
{
    use Spatial;

    protected $spatial = ['your_column'];
}

Now you can go to the tables BREAD-settings and set your field to be Coordinates.

After that you will get a Map where you can select your Coordinates.

Make sure to set the Google Maps API-Key in your . This is also the place where you can define the default location of your map.

Getting the coordinates

You can get the coordinates from your model by calling

$model->getCoordinates();

This will return an array of coordinates with lat as the latitude and lng as the longitude.

configuration