From 1fc96f03b25fd148c76752e39b66905645fcab0f Mon Sep 17 00:00:00 2001 From: Vincent Girol Date: Sat, 24 Dec 2022 00:22:51 +0100 Subject: [PATCH 1/2] Fix method definition --- src/Pages/Template.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Pages/Template.php b/src/Pages/Template.php index e07bec3..e53bfc5 100644 --- a/src/Pages/Template.php +++ b/src/Pages/Template.php @@ -2,17 +2,16 @@ namespace Whitecube\NovaPage\Pages; -use App; -use Closure; use ArrayAccess; -use Carbon\Carbon; use BadMethodCallException; -use Whitecube\NovaPage\Sources\SourceInterface; -use Whitecube\NovaPage\Exceptions\ValueNotFoundException; -use Whitecube\NovaPage\Exceptions\TemplateContentNotFoundException; +use Carbon\Carbon; +use Closure; use Illuminate\Database\Eloquent\Concerns\HasAttributes; use Laravel\Nova\Http\Requests\NovaRequest; use Illuminate\Database\Eloquent\Model; +use Whitecube\NovaPage\Exceptions\TemplateContentNotFoundException; +use Whitecube\NovaPage\Exceptions\ValueNotFoundException; +use Whitecube\NovaPage\Sources\SourceInterface; abstract class Template implements ArrayAccess { @@ -411,7 +410,7 @@ public function __set($attribute, $value) * @param mixed $offset * @return bool */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return ! is_null($this->__get($offset)); } @@ -422,7 +421,7 @@ public function offsetExists($offset) * @param mixed $offset * @return mixed */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->__get($offset); } @@ -434,7 +433,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->__set($offset, $value); } @@ -445,7 +444,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->attributes[$offset]); } From 57232b616bd21fb660b614c723cd9e26da1b8d44 Mon Sep 17 00:00:00 2001 From: Vincent Girol Date: Sat, 28 Jan 2023 23:00:26 +0100 Subject: [PATCH 2/2] Fix error when model has array cast for "attributes" attribute. --- src/Sources/Database.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sources/Database.php b/src/Sources/Database.php index 67c1837..5f28350 100644 --- a/src/Sources/Database.php +++ b/src/Sources/Database.php @@ -3,8 +3,8 @@ namespace Whitecube\NovaPage\Sources; use \App; -use Illuminate\Support\Facades\DB; use Carbon\Carbon; +use Illuminate\Support\Facades\DB; use Whitecube\NovaPage\Pages\Template; class Database implements SourceInterface { @@ -67,7 +67,7 @@ public function fetch(Template $template) $attributes = $this->getParsedAttributes( $template, - $model->attributes ? json_decode($model->attributes, true) : [] + $model->attributes ? (is_array($model->attributes) ? $model->attributes : json_decode($model->attributes, true)) : [] ); return [