2017-11-15 14:00:11 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use App\Models\Player;
|
|
|
|
|
|
|
|
class CheckPlayerOwner
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
if ($pid = $request->input('pid')) {
|
|
|
|
$player = Player::find($pid);
|
|
|
|
|
2018-07-20 14:42:43 +08:00
|
|
|
if ($player->uid != auth()->id()) {
|
2017-11-15 14:00:11 +08:00
|
|
|
return response()->json([
|
|
|
|
'errno' => 1,
|
|
|
|
'msg' => trans('admin.players.no-permission')
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|