Skip to content

Commit

Permalink
feat: fetch all lists related to a user (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidDyberg authored Feb 7, 2025
2 parents 7ddd216 + 1161a05 commit 85fb3b6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Http/Controllers/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
namespace App\Http\Controllers;

use App\Models\MovieList;
use App\Models\User;
use Illuminate\Http\Request;

class ListController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
public function index($username)
{
return view('lists');
$user = User::where('username', $username)->firstOrFail();
$lists = $user->lists()->with('movies')->get();

return view('lists', ['user' => $user, 'lists' => $lists]);
}

/**
Expand Down

0 comments on commit 85fb3b6

Please sign in to comment.