Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Map field #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ First we should create the fields classes and the test cases. After we have to s
- Implement the `Flexible Content` field with unit tests (done!);
- Improve performance. Currently the plugin makes one SQL query for each field. This goal is to improve that using `whereIn()` clauses.

Some fields are still missing (check table below and contribute).

## Fields

Expand All @@ -96,7 +95,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 | [@naeemz](http://github.com/naeemz) | `array` |
| 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` |
Expand Down
34 changes: 34 additions & 0 deletions src/Field/GoogleMap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Corcel\Acf\Field;

use Corcel\Acf\FieldInterface;

/**
* Class GoogleMap.
*
* @author Naeem Ullah <[email protected]>
*/
class GoogleMap extends BasicField implements FieldInterface
{
/**
* @var Array
*/
protected $cords;

/**
* @param string $fieldName
*/
public function process($fieldName)
{
$this->cords = $this->fetchValue($fieldName);
}

/**
* @return Array
*/
public function get()
{
return $this->cords;
}
}
4 changes: 4 additions & 0 deletions src/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Corcel\Acf\Field\DateTime;
use Corcel\Acf\Field\File;
use Corcel\Acf\Field\Gallery;
use Corcel\Acf\Field\GoogleMap;
use Corcel\Acf\Field\Image;
use Corcel\Acf\Field\PageLink;
use Corcel\Acf\Field\PostObject;
Expand Down Expand Up @@ -107,6 +108,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;
}

Expand Down