Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Feb 3, 2021
1 parent d30a446 commit f1950fe
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions src/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Naoray\NovaJson;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Resources\MergeValue;
use Laravel\Nova\Makeable;
use Illuminate\Support\Str;
use Laravel\Nova\Fields\Field;
use Laravel\Nova\Fields\Hidden;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Resources\MergeValue;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Makeable;
use Naoray\NovaJson\Exceptions\AttributeCast;

class JSON extends MergeValue
Expand Down Expand Up @@ -86,14 +86,7 @@ public function fillAtOnce(callable $fillOnceCallback = null)
return $this;
}

/**
* Indicate that the field should be nullable.
*
* @param bool $nullable
* @param array|Closure $values
* @return $this
*/
public function nullable($nullable = true, $values = null)
public function nullable(bool $nullable = true, $values = null)
{
$this->nullable = $nullable;

Expand All @@ -104,26 +97,14 @@ public function nullable($nullable = true, $values = null)
return $this;
}

/**
* Specify nullable values.
*
* @param array|Closure $values
* @return $this
*/
public function nullValues($values)
{
$this->nullValues = $values;

return $this;
}

/**
* Check value for null value.
*
* @param mixed $value
* @return bool
*/
protected function isNullValue($value)
protected function isNullValue($value): bool
{
return is_callable($this->nullValues)
? ($this->nullValues)($value)
Expand Down Expand Up @@ -170,7 +151,7 @@ protected function prepareField(Field $field)
return;
}

if (! $model->hasCast($this->attribute)) {
if (!$model->hasCast($this->attribute)) {
throw AttributeCast::notFoundFor($this->attribute);
}

Expand Down

0 comments on commit f1950fe

Please sign in to comment.