blessing-skin-server/app/Http/Middleware/CheckPlayerOwner.php
Pig Fang 3cf19d8656
Apply fixes from StyleCI (#11)
This pull request applies code style fixes from an analysis carried out by [StyleCI](https://github.styleci.io).

---

For more information, click [here](https://github.styleci.io/analyses/8wKwbZ).
2019-03-02 22:58:37 +08:00

33 lines
683 B
PHP

<?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);
if ($player->uid != auth()->id()) {
return response()->json([
'errno' => 1,
'msg' => trans('admin.players.no-permission'),
]);
}
}
return $next($request);
}
}