Skip to content

Commit 85fb3b6

Browse files
authored
feat: fetch all lists related to a user (#304)
2 parents 7ddd216 + 1161a05 commit 85fb3b6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/Http/Controllers/ListController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\MovieList;
6+
use App\Models\User;
67
use Illuminate\Http\Request;
78

89
class ListController extends Controller
910
{
1011
/**
1112
* Display a listing of the resource.
1213
*/
13-
public function index()
14+
public function index($username)
1415
{
15-
return view('lists');
16+
$user = User::where('username', $username)->firstOrFail();
17+
$lists = $user->lists()->with('movies')->get();
18+
19+
return view('lists', ['user' => $user, 'lists' => $lists]);
1620
}
1721

1822
/**

0 commit comments

Comments
 (0)