You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Http\Middleware;use App\Models\Agent;use App\Models\User;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Cache;
class ApiBase{ public function handle(Request $request, Closure $next) { $appid = request()->header('appid');
if (empty($appid)) { return response()->json([ 'code' => -1, 'msg' => '商户信息缺失', 'data' => [], 'status' => 500, ]); }
//检查代理商
$agent_id = Cache::get($appid); if (empty($agent_id) || $agent_id != Agent::query()->where(['appid' => $appid, 'status' => 1])->value('id')) { return response()->json([ 'code' => -1, 'msg' => '商户不存在或已被禁用', 'data' => [], 'status' => 403, ]); } Cache::put($appid, $agent_id); return $next($request); }}
|