Remove Controller User Model Binding

We're going to being in the user id from the URI instead so we can do a custom lookup on it.
This commit is contained in:
Refringe 2024-09-17 14:51:32 -04:00
parent b67dd2fd97
commit be05d2693e
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k

View File

@ -11,8 +11,12 @@ class UserController extends Controller
{ {
use AuthorizesRequests; use AuthorizesRequests;
public function show(Request $request, User $user, string $username): View 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) { if ($user->slug() !== $username) {
abort(404); abort(404);
} }
@ -21,11 +25,6 @@ class UserController extends Controller
abort(403); abort(403);
} }
// not sure if this is optimal. Some way to do $user->with(...) ???
$user = User::where('id', $user->id)
->with(['followers', 'following'])
->firstOrFail();
return view('user.show', compact('user')); return view('user.show', compact('user'));
} }
} }