From 0b730351e0cf4a1edec6dbcbc6387e1731540ea8 Mon Sep 17 00:00:00 2001 From: Fido van den Bos Date: Thu, 30 Dec 2021 16:16:43 +0100 Subject: [PATCH] Add Google maps support for ACF. --- readme.md | 9 ++++++++- src/Field/GoogleMaps.php | 34 ++++++++++++++++++++++++++++++++++ src/FieldFactory.php | 4 ++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/Field/GoogleMaps.php diff --git a/readme.md b/readme.md index d718b9f..0429c91 100644 --- a/readme.md +++ b/readme.md @@ -19,6 +19,13 @@ For more information about how Corcel works please visit [the repository](http:/ - [Running Tests](#running-tests) * [Licence](#licence) +# Version Compatibility + + Corcel | Laravel | PHP +:----------|:---------|:---------- + `^4.0` | 7.x | `>=7.2` + `^5.0` | 8.x | `>=7.3` + # Installation To install the ACF plugin for Corcel is easy: @@ -96,7 +103,7 @@ First we should create the fields classes and the test cases. After we have to s | Relationship | ok | [@jgrossi](http://github.com/jgrossi) | `Corcel\Post` or `Collection` of `Post` | | Taxonomy | ok | [@jgrossi](http://github.com/jgrossi) | `Corcel\Term` or `Collection` of `Term` | | User | ok | [@jgrossi](http://github.com/jgrossi) | `Corcel\User` | -| Google Map | missing | | +| Google Map | ok | [@fidovdbos](https://github.com/fidovdbos)| `Corcel\Acf\Field\GoogleMap` | | Date Picker | ok | [@jgrossi](http://github.com/jgrossi) | `Carbon\Carbon` | | Date Time Picker | ok | [@jgrossi](http://github.com/jgrossi) | `Carbon\Carbon` | | Time Picker | ok | [@jgrossi](http://github.com/jgrossi) | `Carbon\Carbon` | diff --git a/src/Field/GoogleMaps.php b/src/Field/GoogleMaps.php new file mode 100644 index 0000000..8fcf557 --- /dev/null +++ b/src/Field/GoogleMaps.php @@ -0,0 +1,34 @@ + + */ +class GoogleMap extends BasicField implements FieldInterface +{ + /** + * @var Array + */ + protected $data; + + /** + * @param string $fieldName + */ + public function process($fieldName) + { + $this->data = $this->fetchValue($fieldName); + } + + /** + * @return Array + */ + public function get() + { + return $this->data; + } +} diff --git a/src/FieldFactory.php b/src/FieldFactory.php index 2709458..6290401 100644 --- a/src/FieldFactory.php +++ b/src/FieldFactory.php @@ -15,6 +15,7 @@ use Corcel\Acf\Field\Term; use Corcel\Acf\Field\Text; use Corcel\Acf\Field\User; +use Corcel\Acf\Field\GoogleMap; use Corcel\Model; use Illuminate\Support\Collection; @@ -108,6 +109,9 @@ public static function make($name, Model $post, $type = null) case 'flexible_content': $field = new FlexibleContent($post); break; + case 'google_map': + $field = new GoogleMap($post); + break; default: return null; }