diff --git a/app/Nova/GirlsInDigitalPage.php b/app/Nova/GirlsInDigitalPage.php index 074da11a1..59d1c8de4 100644 --- a/app/Nova/GirlsInDigitalPage.php +++ b/app/Nova/GirlsInDigitalPage.php @@ -103,6 +103,9 @@ private function localeField(string $label, string $locale, string $key, bool $t : Text::make($label, $attr)->nullable(); } $field->resolveUsing(function () use ($locale, $key) { + if (! $this->resource) { + return ''; + } $overrides = $this->resource->locale_overrides ?? []; return $overrides[$locale][$key] ?? ''; }); @@ -140,6 +143,20 @@ private function buttonFields(string $key, string $title): array } public function fields(Request $request): array + { + try { + return $this->buildFields($request); + } catch (\Throwable $e) { + report($e); + return [ + ID::make()->onlyOnForms(), + \Laravel\Nova\Fields\Heading::make('Error loading form: ' . $e->getMessage()), + \Laravel\Nova\Fields\Heading::make('File: ' . $e->getFile() . ' Line: ' . $e->getLine()), + ]; + } + } + + private function buildFields(Request $request): array { $locales = self::localesSorted(); @@ -269,7 +286,7 @@ public function fields(Request $request): array private function getButtonField(string $key, string $field) { try { - if (! \Illuminate\Support\Facades\Schema::hasTable('girls_in_digital_buttons')) { + if (! $this->resource || ! \Illuminate\Support\Facades\Schema::hasTable('girls_in_digital_buttons')) { return $field === 'enabled' ? true : ($field === 'open_new_tab' ? false : ''); } $button = $this->resource->buttons()->where('key', $key)->first();