Skip to content

Commit

Permalink
apply styles
Browse files Browse the repository at this point in the history
  • Loading branch information
eisfeuer committed Oct 14, 2020
1 parent 887cf9c commit e310893
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 47 deletions.
27 changes: 20 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"require": {
"php": ">=7.1.0"
},
"autoload": {
"psr-4": {
"Elbgoods\\NovaAddressField\\": "src/"
}
"require-dev": {
"elbgoods/ci-test-tools": "^1.12"
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
Expand All @@ -21,9 +22,21 @@
]
}
},
"config": {
"sort-packages": true
"autoload": {
"psr-4": {
"Elbgoods\\NovaAddressField\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"scripts": {
"fix": "vendor/bin/php-cs-fixer fix --using-cache=no --config=vendor/elbgoods/ci-test-tools/configs/.php_cs.dist src",
"test": [
"vendor/bin/phpmnd src --non-zero-exit-on-violation",
"vendor/bin/phpmd src text vendor/elbgoods/ci-test-tools/configs/phpmd.xml",
"vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --config=vendor/elbgoods/ci-test-tools/configs/.php_cs.dist src",
"vendor/bin/tlint lint src --no-interaction",
"vendor/bin/phpinsights analyse --config-path=vendor/elbgoods/ci-test-tools/configs/phpinsights.php --no-interaction -v --disable-security-check --min-quality=100 --min-architecture=100 --min-style=100 src"
]
}
}
7 changes: 3 additions & 4 deletions src/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class FieldServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
Nova::serving(function (ServingNova $event) {
Nova::serving(static function (ServingNova $event): void {
Nova::script('nova-address-field', __DIR__.'/../dist/js/field.js');
Nova::style('nova-address-field', __DIR__.'/../dist/css/field.css');
});
Expand All @@ -26,8 +26,7 @@ public function boot()
*
* @return void
*/
public function register()
public function register(): void
{
//
}
}
70 changes: 34 additions & 36 deletions src/NovaAddressField.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,89 +7,70 @@

class NovaAddressField extends Field
{
public function __construct($name, $attribute = null, callable $resolveCallback = null)
{
parent::__construct($name, $attribute, $resolveCallback);

$this->latitude('latitude')
->longitude('longitude')
->fieldOptions([])
->at(53.54923, 9.98832);
}

/**
* The field's component.
*
* @var string
*/
public $component = 'nova-address-field';

/**
* Hydrate the given attribute on the model based on the incoming request.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param string $requestAttribute
* @param object $model
* @param string $attribute
* @return void
*/
protected function fillAttributeFromRequest(NovaRequest $request,
$requestAttribute,
$model,
$attribute): void
public function __construct(string $name, ?string $attribute = null, ?callable $resolveCallback = null)
{
if ($request->exists($requestAttribute)) {
$model->{$attribute} = json_decode($request[$requestAttribute], true);
}
parent::__construct($name, $attribute, $resolveCallback);

$this->latitude('latitude')
->longitude('longitude')
->fieldOptions([])
->at(53.54923, 9.98832);
}

public function usingHere(): self
{
return $this->withMeta([
'geo_provider' => 'here',
'api_url' => 'https://discover.search.hereapi.com/v1/discover'
'api_url' => 'https://discover.search.hereapi.com/v1/discover',
]);
}

public function withApiKey(string $apiKey): self
{
return $this->withMeta([
'api_key' => $apiKey
'api_key' => $apiKey,
]);
}

public function proxied(): self
{
return $this->withMeta([
'is_proxy' => true
'is_proxy' => true,
]);
}

public function withUrl($url): self
public function withUrl(string $url): self
{
return $this->withMeta([
'api_url' => $url
'api_url' => $url,
]);
}

public function fieldOptions(array $fieldOptions): self
{
return $this->withMeta([
'field_options' => $fieldOptions
'field_options' => $fieldOptions,
]);
}

public function searchLabel(string $label): self
{
return $this->withMeta([
'search_label' => $label
'search_label' => $label,
]);
}

public function at(float $latitude, float $longitude): self
public function referencePoint(float $latitude, float $longitude): self
{
return $this->withMeta([
'here_at' => implode(',', [$latitude, $longitude])
'here_at' => implode(',', [$latitude, $longitude]),
]);
}

Expand All @@ -102,4 +83,21 @@ public function longitude(string $field): self
{
return $this->withMeta([__FUNCTION__ => $field]);
}

/**
* Hydrate the given attribute on the model based on the incoming request.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param string $requestAttribute
* @param object $model
* @param string $attribute
*
* @return void
*/
protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute): void
{
if ($request->exists($requestAttribute)) {
$model->{$attribute} = json_decode($request[$requestAttribute], true);
}
}
}

0 comments on commit e310893

Please sign in to comment.