refactor: use route model binding for user controllers

This commit is contained in:
Roardom
2022-12-29 16:13:27 -06:00
parent 5af0731b00
commit 7f1de1718f
23 changed files with 56 additions and 77 deletions
+1 -2
View File
@@ -21,9 +21,8 @@ class PostController extends Controller
/**
* Show user posts.
*/
public function index(string $username): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
public function index(User $user): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
$user = User::where('username', '=', $username)->sole();
$posts = $user->posts()->with(['topic', 'user'])->latest()->paginate(25);
return \view('user.post.index', [