PHP code example of arbermustafa / filament-locationpickr-field
1. Go to this page and download the library: Download arbermustafa/filament-locationpickr-field library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arbermustafa / filament-locationpickr-field example snippets
...
Schema::table('table_name', function (Blueprint $table) {
$table->json('location')->nullable();
});
...
...
protected $fillable = [
...
'location',
];
...
protected $appends = [
...
'location',
];
...
public function location(): Attribute
{
return Attribute::make(
get: fn ($value, $attributes) => json_encode([
'lat' => (float) $attributes['lat'],
'lng' => (float) $attributes['lng'],
]),
set: fn ($value) => [
'lat' => $value['lat'],
'lng' => $value['lng'],
],
);
}
...
use ArberMustafa\FilamentLocationPickrField\Forms\Components\LocationPickr;
...
->schema([
...
LocationPickr::make('location'),
....
]);
...
use ArberMustafa\FilamentLocationPickrField\Forms\Components\LocationPickr;
...
->schema([
...
LocationPickr::make('location')
->mapControls([
'mapTypeControl' => true,
'scaleControl' => true,
'streetViewControl' => true,
'rotateControl' => true,
'fullscreenControl' => true,
'zoomControl' => false,
])
->defaultZoom(5)
->draggable()
->clickable()
->height('40vh')
->defaultLocation([41.32836109345274, 19.818383186960773])
->myLocationButtonLabel('My location'),
....
]);
...
use ArberMustafa\FilamentLocationPickrField\Infolists\Components\LocationPickr;
...
->schema([
...
LocationPickr::make('location'),
....
]);
...
bash
php artisan vendor:publish --tag=filament-locationpickr-field-config
bash
php artisan vendor:publish --tag=filament-locationpickr-field-views