gian_tiaga/moonshine-coordinates

月亮管理面板的地图坐标字段

1.0.2 2024-06-12 12:31 UTC

This package is not auto-updated.

Last update: 2024-09-19 12:04:34 UTC


README

安装

composer require gian_tiaga/moonshine-coordinates

使用

  1. 在迁移中添加坐标字段
$table->json('coordinates')->nullable();
  1. 在模型中添加 cast
use GianTiaga\MoonshineCoordinates\Casts\CoordinatesCast;

// ...code

/**
 * @return array<string, string>
 */
protected function casts(): array
{
    return [
        'coordinates' => CoordinatesCast::class,
    ];
}
  1. 在资源中使用字段
use GianTiaga\MoonshineCoordinates\Dto\CoordinatesDto;
use GianTiaga\MoonshineCoordinates\Fields\Coordinates;

// ...code

Coordinates::make('Расположение', 'coordinates')
    ->center(new CoordinatesDto(
        latitude: 55.7505412, 
        longitude: 37.6174782
    ))
    ->zoom(10), 

外观如下

demo