Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
rc-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Traineratwot committed Jan 18, 2024
1 parent 035275a commit c6a7214
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 90 deletions.
111 changes: 89 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is my package filament-openstreetmap
# This is filament-openstreetmap

[![Latest Version on Packagist](https://img.shields.io/packagist/v/traineratwot/filament-openstreetmap.svg?style=flat-square)](https://packagist.org/packages/traineratwot/filament-openstreetmap)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/traineratwot/filament-openstreetmap/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/traineratwot/filament-openstreetmap/actions?query=workflow%3Arun-tests+branch%3Amain)
Expand All @@ -7,7 +7,7 @@



This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
**Add openstreetmap field to filament form**

## Installation

Expand All @@ -17,39 +17,101 @@ You can install the package via composer:
composer require traineratwot/filament-openstreetmap
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="filament-openstreetmap-migrations"
php artisan migrate
```
## Usage

You can publish the config file with:
Make model with migration

```bash
php artisan vendor:publish --tag="filament-openstreetmap-config"
1)
```php

return new class extends Migration {
public function up(): void
{
Schema::create('map_points', function (Blueprint $table) {
$table->id();
$table->point('point')->nullable(); // for Point type
$table->string('point_string')->nullable(); // for String type
$table->json('point_array')->nullable(); // for Array type
$table->timestamps();
});
}

public function down(): void
{
Schema::dropIfExists('map_points');
}
};
```
2)

Optionally, you can publish the views using
```php
namespace App\Models;

```bash
php artisan vendor:publish --tag="filament-openstreetmap-views"
```
use MatanYadaev\EloquentSpatial\Objects\Point;
use Illuminate\Database\Eloquent\Model;

This is the contents of the published config file:
class MapPoint extends Model
{

```php
return [
];
protected $casts = [
'point' => Point::class, // Important for Point type
'point_array' => 'array', // Important for Array type
];

...
}
```

## Usage
Make filametn resource

```php
$filamentOpenStreetMap = new Traineratwot\FilamentOpenStreetMap();
echo $filamentOpenStreetMap->echoPhrase('Hello, Traineratwot!');

<?php

namespace App\Filament\Resources;

use Traineratwot\FilamentOpenStreetMap\Forms\Components\MapInput;


class MapPointResource extends Resource
{
protected static ?string $model = MapPoint::class;

public static function form(Form $form): Form
{
return $form
->schema([
MapInput::make('point')
->saveAsPoint() // Important for Point type
->placeholder('Choose your location')
->coordinates(37.619, 55.7527) // start coordinates
->rows(10) // height of map
,

MapInput::make('point_string')
->saveAsString() // default
->placeholder('Choose your location')
->coordinates(37.619, 55.7527) // start coordinates
->rows(10) // height of map
,

MapInput::make('point_array')
->saveAsArray() // Important for Array type
->placeholder('Choose your location')
->coordinates(37.619, 55.7527) // start coordinates
->rows(10) // height of map
,

]);
}
...
}


```



## Testing

```bash
Expand All @@ -76,3 +138,8 @@ Please review [our security policy](../../security/policy) on how to report secu
## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## used packages
composer: matanyadaev/laravel-eloquent-spatial
npm: ol
npm: ol-geocoder
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"filament/filament": "^3.2",
"filament/forms": "^3.2",
"illuminate/contracts": "^10.0",
"matanyadaev/laravel-eloquent-spatial": "^3.2",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
Expand Down
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"private": true,
"type": "module",
"scripts": {
"dev:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/filament-openstreetmap.css --postcss --watch",
"dev:styles": "npx tailwindcss -i resources/css/index.scss -o resources/dist/filament-openstreetmap.css --postcss --watch",
"dev:scripts": "node bin/build.js --dev",
"build:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/filament-openstreetmap.css --postcss --minify && npm run purge",
"build:styles": "npx tailwindcss -i resources/css/index.scss -o resources/dist/filament-openstreetmap.css --postcss --minify && npm run purge",
"build:scripts": "node bin/build.js",
"purge": "filament-purge -i resources/dist/filament-openstreetmap.css -o resources/dist/filament-openstreetmap.css -v 3.x",
"dev": "npm-run-all --parallel dev:*",
Expand All @@ -24,6 +24,7 @@
"tailwindcss": "^3.3.3"
},
"dependencies": {
"ol": "^8.2.0"
"ol": "^8.2.0",
"ol-geocoder": "^4.3.1"
}
}
1 change: 0 additions & 1 deletion resources/css/index.css

This file was deleted.

6 changes: 6 additions & 0 deletions resources/css/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '../../node_modules/ol/ol.css';
@import '../../node_modules/ol-geocoder/dist/ol-geocoder.min.css';

.gcd-txt-control {
color: #09090b !important;
}
Loading

0 comments on commit c6a7214

Please sign in to comment.