blessing-skin-server/app/Http/Middleware/CheckPlayerExist.php
2020-01-12 17:14:23 +08:00

20 lines
470 B
PHP

<?php
namespace App\Http\Middleware;
use App\Models\Player;
use Illuminate\Support\Arr;
class CheckPlayerExist
{
public function handle($request, \Closure $next)
{
$pid = Arr::get($request->route()->parameters, 'pid') ?? $request->input('pid');
if (!$request->isMethod('get') && !is_null($pid) && is_null(Player::find($pid))) {
return json(trans('general.unexistent-player'), 1);
}
return $next($request);
}
}