Skip to content
Merged

Dev #3332

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion app/Nova/GirlsInDigitalPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] ?? '';
});
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
Loading