mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
We're going to being in the user id from the URI instead so we can do a custom lookup on it.
31 lines
692 B
PHP
31 lines
692 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class UserController extends Controller
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public function show(Request $request, int $userId, string $username): View
|
|
{
|
|
$user = User::where('id', $userId)
|
|
// Reimplement eager loading after the review.
|
|
->firstOrFail();
|
|
|
|
if ($user->slug() !== $username) {
|
|
abort(404);
|
|
}
|
|
|
|
if ($request->user()?->cannot('view', $user)) {
|
|
abort(403);
|
|
}
|
|
|
|
return view('user.show', compact('user'));
|
|
}
|
|
}
|