diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2929342a..b96eccfb 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -46,7 +46,10 @@ class AppServiceProvider extends ServiceProvider View::composer('*', function (\Illuminate\View\View $view) { /** @var Group $group */ $group = Auth::check() ? Auth::user()->group : Group::query()->where('is_guest', true)->first(); - $view->with('_group', $group); + $view->with([ + '_group' => $group, + '_is_notice' => strip_tags(Utils::config(ConfigKey::SiteNotice)), + ]); }); } } diff --git a/resources/views/common/notice.blade.php b/resources/views/common/notice.blade.php index e4d868cd..e0fd2935 100644 --- a/resources/views/common/notice.blade.php +++ b/resources/views/common/notice.blade.php @@ -1,4 +1,4 @@ -@if(strip_tags(\App\Utils::config(\App\Enums\ConfigKey::SiteNotice))) +@if($_is_notice)
@@ -12,10 +12,15 @@ @push('scripts') diff --git a/resources/views/layouts/header.blade.php b/resources/views/layouts/header.blade.php index 5efb9b86..56506eb2 100644 --- a/resources/views/layouts/header.blade.php +++ b/resources/views/layouts/header.blade.php @@ -7,9 +7,8 @@ @yield('title', \App\Utils::config(\App\Enums\ConfigKey::AppName))
- @if($_group->strategies->isNotEmpty()) - @include('layouts.strategies') - @endif + @includeWhen($_is_notice, 'layouts.notice') + @includeWhen($_group->strategies->isNotEmpty(), 'layouts.strategies') @include('layouts.user-nav')
diff --git a/resources/views/layouts/notice.blade.php b/resources/views/layouts/notice.blade.php new file mode 100644 index 00000000..d4a0667a --- /dev/null +++ b/resources/views/layouts/notice.blade.php @@ -0,0 +1,15 @@ +@if($_is_notice) + + @push('scripts') + + @endpush +@endif diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index c4cb875a..228a5205 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -10,9 +10,8 @@ {{ \App\Utils::config(\App\Enums\ConfigKey::AppName) }}
- @if($_group->strategies->isNotEmpty()) - @include('layouts.strategies') - @endif + @includeWhen($_is_notice, 'layouts.notice') + @includeWhen($_group->strategies->isNotEmpty(), 'layouts.strategies') @if(Auth::check()) @include('layouts.user-nav')