qcod / laravel-app-settings

Store settings in database with a manager UI for your Laravel app
MIT License
338 stars 53 forks source link

Use in Middleware #21

Closed LadyNay closed 4 years ago

LadyNay commented 4 years ago

Hi,

I am battling to get the value of the settings or checking it. I want to check if the setting is 'yes' then the maintenance page will show if not then not.

I am using it in the middleware and have called it in the boot like you showed me the last time: <?php

namespace App\Http\Middleware;

use Closure;

class MaintenanceMode { /**

LadyNay commented 4 years ago

Tried this as well: I get the page now, though the status is not being picked up and the page shows regardless: public function handle($request, Closure $next) { if(AppSetting::get('app_maintenance') == 'yes') { return redirect()->route('maintenance'); } else { return $next($request); } }

LadyNay commented 4 years ago

public function handle($request, Closure $next) { if(setting('app_maintenance') == true) { return Response::view('frontend.single_pages.maintenancemode'); } else { return $next($request); } }

I think my app was just stuck, but the above works if anyone needs the code.