@php
- $isShopOffline = \App\Models\Setting::get('shop_offline', '0') === '1';
+ $isShopOffline = false;
+ try {
+ if (\Illuminate\Support\Facades\Schema::hasTable('settings')) {
+ $isShopOffline = \App\Models\Setting::get('shop_offline', '0') === '1';
+ }
+ } catch (\Throwable $e) {
+ $isShopOffline = false;
+ }
@endphp
@@ -175,7 +196,7 @@
- @if($isShopOffline ?? (\App\Models\Setting::get('shop_offline', '0') === '1'))
+ @if(!empty($isShopOffline))
diff --git a/tests/Feature/CustomerCommunicationTest.php b/tests/Feature/CustomerCommunicationTest.php
index 1d1e788..9c430b2 100644
--- a/tests/Feature/CustomerCommunicationTest.php
+++ b/tests/Feature/CustomerCommunicationTest.php
@@ -10,6 +10,7 @@ use App\Models\Order;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Mail;
+use Illuminate\Support\Facades\Schema;
use Tests\TestCase;
class CustomerCommunicationTest extends TestCase
@@ -231,4 +232,14 @@ class CustomerCommunicationTest extends TestCase
$this->actingAs($this->customer)->get(route('admin.communications.index'))->assertRedirect(route('home'));
$this->actingAs($this->customer)->get(route('admin.customers.index'))->assertRedirect(route('home'));
}
+
+ public function test_admin_layout_does_not_crash_even_if_communications_table_is_initially_missing(): void
+ {
+ Schema::dropIfExists('communication_replies');
+ Schema::dropIfExists('communications');
+
+ // Layout renders with HTTP 200 without 500 server error even when table was absent
+ $response = $this->actingAs($this->admin)->get(route('admin.content.index'));
+ $response->assertStatus(200);
+ }
}