mirror of
https://github.com/KevinMidboe/nova-map-fields.git
synced 2025-10-29 17:50:27 +00:00
Testing new navigation route
This commit is contained in:
40
src/NavigationRoute.php
Normal file
40
src/NavigationRoute.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Lassehaslev\NovaMapFields;
|
||||
|
||||
class Polyline extends MapField
|
||||
{
|
||||
/**
|
||||
* Create a new field.
|
||||
* And set default properties.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|null $attribute
|
||||
* @param mixed|null $resolveCallback
|
||||
*/
|
||||
public function __construct($name, $attribute = null, $resolveCallback = null)
|
||||
{
|
||||
$this->help('Click on the map to create a new point. Drag a marker to change the point. When the map is selected, you can press [backspace] to remove markers.');
|
||||
|
||||
parent::__construct($name, $attribute = null, $resolveCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the attribute before sending to frontend.
|
||||
*
|
||||
* @param mixed $resource
|
||||
* @param mixed|null $attribute
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function resolveAttribute($resource, $attribute = null)
|
||||
{
|
||||
$value = $resource->{$attribute};
|
||||
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return json_decode($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user