From b23d9351b5f372844ae2e6f57be673cf352705e5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 7 Jun 2024 15:08:50 +1000 Subject: [PATCH] Make $setup available to all blades --- app/Http/Middleware/AddUserToView.php | 3 +++ resources/views/dashboard.blade.php | 2 -- resources/views/system/widget/system.blade.php | 4 ++-- resources/views/user/system/register.blade.php | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Http/Middleware/AddUserToView.php b/app/Http/Middleware/AddUserToView.php index 2e3e725..b06f0b9 100644 --- a/app/Http/Middleware/AddUserToView.php +++ b/app/Http/Middleware/AddUserToView.php @@ -6,6 +6,8 @@ use Closure; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\Auth\Authenticatable; +use App\Models\Setup; + class AddUserToView { /** @@ -44,6 +46,7 @@ class AddUserToView public function handle($request, Closure $next) { $this->factory->share('user',$this->user); + $this->factory->share('setup',Setup::find(config('app.id'))); return $next($request); } diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 0f41107..302b7a4 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -5,9 +5,7 @@ @php use App\Classes\Protocol\Binkp; -use App\Models\Setup; $user->load(['systems.akas.zone.domain.echoareas','systems.akas.echoareas']); -$setup = Setup::findOrFail(config('app.id')); @endphp @section('content') diff --git a/resources/views/system/widget/system.blade.php b/resources/views/system/widget/system.blade.php index e5056a5..7a35a7a 100644 --- a/resources/views/system/widget/system.blade.php +++ b/resources/views/system/widget/system.blade.php @@ -1,6 +1,6 @@ @php use App\Classes\FTN\Packet; -use App\Models\{Mailer,Setup,User}; +use App\Models\{Mailer,User}; @endphp @@ -195,7 +195,7 @@ use App\Models\{Mailer,Setup,User};
- + @error('pkt_msgs') {{ $message }} diff --git a/resources/views/user/system/register.blade.php b/resources/views/user/system/register.blade.php index f35a567..ed9a547 100644 --- a/resources/views/user/system/register.blade.php +++ b/resources/views/user/system/register.blade.php @@ -5,7 +5,7 @@ @endsection @php -use App\Models\{Setup,System}; +use App\Models\System; @endphp @section('content') @@ -28,7 +28,7 @@ use App\Models\{Setup,System}; @foreach (System::select(['systems.id','systems.name']) ->active() - ->where('id','<>',Setup::findOrFail(config('app.id'))->system_id) + ->where('id','<>',$setup->system_id) ->whereRaw('id NOT IN (SELECT system_id FROM system_user)') ->cursor() as $oo)