Skip to content

Commit

Permalink
Merge pull request #236 from 64robots/update/support-nova-v4
Browse files Browse the repository at this point in the history
Update/support nova v4
  • Loading branch information
NtimYeboah authored May 31, 2024
2 parents d3492da + ecd6a15 commit 9dcc0db
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 68 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"license": "MIT",
"require": {
"php": ">=7.1.0"
"php": "^7.1|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 8 additions & 8 deletions src/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BelongsTo extends NovaBelongsTo
* @param mixed $resource
* @return array
*/
public function formatAssociatableResource(NovaRequest $request, $resource)
public function formatAssociatableResource(NovaRequest $request, $resource): array
{
$relation = explode(".", $this->groupedBy);

Expand All @@ -76,7 +76,7 @@ public function formatAssociatableResource(NovaRequest $request, $resource)
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function getRules(NovaRequest $request)
public function getRules(NovaRequest $request): array
{
$rules = parent::getRules($request);

Expand All @@ -96,7 +96,7 @@ public function getRules(NovaRequest $request)
* @param string $field
* @return $this
*/
public function groupedBy($field)
public function groupedBy($field): BelongsTo
{
$this->groupedBy = $field;

Expand All @@ -109,7 +109,7 @@ public function groupedBy($field)
* @param string $name
* @return $this
*/
public function displayName($name)
public function displayName($name): BelongsTo
{
$this->displayName = $name;

Expand All @@ -121,7 +121,7 @@ public function displayName($name)
*
* @return $this
*/
public function disableRelatableRule()
public function disableRelatableRule(): BelongsTo
{
$this->disableRelatableRule = true;

Expand All @@ -133,7 +133,7 @@ public function disableRelatableRule()
*
* @return $this
*/
public function quickCreate($fillValues = [])
public function quickCreate($fillValues = []): BelongsTo
{
$this->withMeta(['quickCreate' => true, 'fillValues' => $fillValues]);

Expand All @@ -145,7 +145,7 @@ public function quickCreate($fillValues = [])
*
* @return $this
*/
public function disableTrashed()
public function disableTrashed(): BelongsTo
{
$this->withMeta(['disableTrashed' => true]);

Expand All @@ -157,7 +157,7 @@ public function disableTrashed()
*
* @return array
*/
public function meta()
public function meta(): array
{
return array_merge([
'wrapperClasses' => $this->wrapperClasses,
Expand Down
12 changes: 6 additions & 6 deletions src/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Boolean extends NovaBoolean
* @param string $classes
* @return $this
*/
public function dotClasses($classes)
public function dotClasses($classes): Boolean
{
return $this->withMeta(['dotClasses' => $classes]);
}
Expand All @@ -46,7 +46,7 @@ public function dotClasses($classes)
* @param string $class
* @return $this
*/
public function successClass($class)
public function successClass($class): Boolean
{
return $this->withMeta(['successClass' => $class]);
}
Expand All @@ -57,7 +57,7 @@ public function successClass($class)
* @param string $class
* @return $this
*/
public function dangerClass($class)
public function dangerClass($class): Boolean
{
return $this->withMeta(['dangerClass' => $class]);
}
Expand All @@ -68,7 +68,7 @@ public function dangerClass($class)
* @param string $label
* @return $this
*/
public function yesLabel($label)
public function yesLabel($label): Boolean
{
return $this->withMeta(['yesLabel' => $label]);
}
Expand All @@ -79,7 +79,7 @@ public function yesLabel($label)
* @param string $label
* @return $this
*/
public function noLabel($label)
public function noLabel($label): Boolean
{
return $this->withMeta(['noLabel' => $label]);
}
Expand All @@ -89,7 +89,7 @@ public function noLabel($label)
*
* @return $this
*/
public function hideBooleanLabel()
public function hideBooleanLabel(): Boolean
{
return $this->withMeta(['hideBooleanLabel' => true]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Currency extends NovaCurrency
*
* @return $this
*/
public function colors()
public function colors(): Currency
{
return $this->withMeta(['colors' => true]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DateTime extends NovaDateTime
*
* @return $this
*/
public function hideTimezone()
public function hideTimezone(): DateTime
{
return $this->withMeta(['hideTimezone' => true]);
}
Expand Down
6 changes: 3 additions & 3 deletions src/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FieldServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
Nova::serving(function (ServingNova $event) {
Nova::script('nova-fields', __DIR__.'/../dist/js/field.js');
Expand All @@ -31,7 +31,7 @@ public function boot()
*
* @return void
*/
public function register()
public function register(): void
{
//
}
Expand All @@ -41,7 +41,7 @@ public function register()
*
* @return array
*/
protected function routeConfiguration()
protected function routeConfiguration(): array
{
return [
'namespace' => 'R64\NovaFields\Http\Controllers',
Expand Down
6 changes: 3 additions & 3 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($name, $attribute = null, $disk = 'public', $storage
*
* @return $this
*/
public function draggable()
public function draggable(): File
{
return $this->withMeta(['draggable' => true]);
}
Expand All @@ -68,7 +68,7 @@ public function draggable()
*
* @return $this
*/
public function previewBeforeUpload()
public function previewBeforeUpload(): File
{
return $this->withMeta(['previewBeforeUpload' => true]);
}
Expand All @@ -78,7 +78,7 @@ public function previewBeforeUpload()
*
* @return array
*/
public function meta()
public function meta(): array
{
return array_merge([
'wrapperClasses' => $this->wrapperClasses,
Expand Down
6 changes: 3 additions & 3 deletions src/HasChilds.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function childConfig($childConfig)
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function getRules(NovaRequest $request)
public function getRules(NovaRequest $request): array
{
$result = [];

Expand All @@ -46,7 +46,7 @@ public function getRules(NovaRequest $request)
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array|string
*/
public function getCreationRules(NovaRequest $request)
public function getCreationRules(NovaRequest $request): array
{
$result = [];

Expand All @@ -69,7 +69,7 @@ public function getCreationRules(NovaRequest $request)
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function getUpdateRules(NovaRequest $request)
public function getUpdateRules(NovaRequest $request): array
{
$result = [];

Expand Down
6 changes: 3 additions & 3 deletions src/Http/Controllers/AssociatableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class AssociatableController extends Controller
/**
* List the available related resources for a given resource.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return \Illuminate\Http\Response
* @param Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function index(NovaRequest $request)
public function index(NovaRequest $request): array
{
$fields = $request->newResource()
->availableFields($request);
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/ComputedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class ComputedController
/**
* Compute the value.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param Laravel\Nova\Http\Requests\NovaRequest $request
* @return mixed
*/
public function index(NovaRequest $request)
public function index(NovaRequest $request): mixed
{
$resourceId = $request->input('resourceId');
$resourceClass = Nova::resourceForKey($request->resource);
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ComputedValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct($values)
return $this->values = (object) $values;
}

public function __get($key)
public function __get($key): bool
{
return property_exists($this->values, $key) ? $this->values->$key : null;
}
Expand Down
9 changes: 5 additions & 4 deletions src/Http/Controllers/FieldDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

namespace R64\NovaFields\Http\Controllers;

use Laravel\Nova\Fields\File;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Laravel\Nova\Fields\File;
use Laravel\Nova\Http\Requests\NovaRequest;

class FieldDownloadController extends Controller
{
/**
* Download the given field's contents.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return \Illuminate\Http\Response
* @param Laravel\Nova\Http\Requests\NovaRequest $request
* @return Illuminate\Http\Response
*/
public function show(NovaRequest $request)
public function show(NovaRequest $request): Response
{
$resource = $request->findResourceOrFail();

Expand Down
2 changes: 1 addition & 1 deletion src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Image extends NovaImage
*
* @return array
*/
public function meta()
public function meta(): array
{
return array_merge([
'wrapperClasses' => $this->wrapperClasses,
Expand Down
14 changes: 7 additions & 7 deletions src/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct($name, $fields, $attribute = null, $resolveCallback
* @param string $classes
* @return $this
*/
public function panelTitleClasses($classes)
public function panelTitleClasses($classes): JSON
{
$this->panelTitleClasses = $classes;

Expand All @@ -101,7 +101,7 @@ public function panelTitleClasses($classes)
*
* @return $this
*/
public function flatten($value = true)
public function flatten($value = true): JSON
{
return $this->withMeta([
'flatten' => $value
Expand All @@ -115,7 +115,7 @@ public function flatten($value = true)
* @param string|null $attribute
* @return void
*/
public function resolve($resource, $attribute = null)
public function resolve($resource, $attribute = null): void
{
$attribute = $attribute ?? $this->attribute;

Expand Down Expand Up @@ -151,7 +151,7 @@ public function resolve($resource, $attribute = null)
* @param string $attribute
* @return void
*/
protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute)
protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute): void
{
$this->fields->each(function ($field) use ($request, $model, $attribute) {
$field->fillInto($request, $model, $attribute . '->' . $field->attribute, $attribute . '.' . $field->attribute);
Expand All @@ -164,7 +164,7 @@ protected function fillAttributeFromRequest(NovaRequest $request, $requestAttrib
* @param array $rules
* @return array
*/
protected function generateRules($rules)
protected function generateRules($rules): array
{
return collect($rules)->mapWithKeys(function ($rules, $key) {
return [$this->attribute . ($key ? '.' . $key : '') => $rules];
Expand All @@ -178,7 +178,7 @@ protected function generateRules($rules)
* @param string|null $attribute
* @return void
*/
public function resolveForDisplay($resource, $attribute = null)
public function resolveForDisplay($resource, $attribute = null): void
{
$attribute = $attribute ?? $this->attribute;

Expand All @@ -196,7 +196,7 @@ public function resolveForDisplay($resource, $attribute = null)
*
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return array_merge(parent::jsonSerialize(), [
'panelTitleClasses' => $this->panelTitleClasses,
Expand Down
2 changes: 1 addition & 1 deletion src/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Number extends NovaNumber
*
* @return $this
*/
public function colors()
public function colors(): Number
{
return $this->withMeta(['colors' => true]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Password extends NovaPassword
* @param string $placeholder
* @return $this
*/
public function maskLabel($label)
public function maskLabel($label): Password
{
return $this->withMeta(['maskLabel' => $label]);
}
Expand Down
Loading

0 comments on commit 9dcc0db

Please sign in to comment.