From 10fc17a81dc61be01cb1b98bbcfb067ba4d9c922 Mon Sep 17 00:00:00 2001 From: Gilles Felix Date: Thu, 26 Sep 2024 16:29:37 +0200 Subject: [PATCH] Fix CurrentModel not initialized --- resources/views/meta.blade.php | 2 +- src/Services/CurrentModelService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/meta.blade.php b/resources/views/meta.blade.php index 442bf16..fe5d6ef 100644 --- a/resources/views/meta.blade.php +++ b/resources/views/meta.blade.php @@ -1,7 +1,7 @@ @php /** @var \Illuminate\Database\Eloquent\Model&\Novius\LaravelMeta\Traits\HasMeta|null $model */ $model = \Novius\LaravelMeta\Facades\CurrentModel::getModel(); -if (!in_array(\Novius\LaravelMeta\Traits\HasMeta::class, class_uses_recursive($model), true)) { +if ($model === null || !in_array(\Novius\LaravelMeta\Traits\HasMeta::class, class_uses_recursive($model), true)) { $model = null; } @endphp diff --git a/src/Services/CurrentModelService.php b/src/Services/CurrentModelService.php index 8db63ca..c7664a3 100644 --- a/src/Services/CurrentModelService.php +++ b/src/Services/CurrentModelService.php @@ -10,7 +10,7 @@ class CurrentModelService { - public ?Model $model; + public ?Model $model = null; public function setModel(Model $model): void {