Can you show us your view? That is where your error is occurring.
Assumption being made: With courses being plural, you should probably be using get instead of first to get all of the courses and not just the first one.
$courses = DB::table('courses')->where('user_id', '1')->get();
If you want to use Auth::user()->id you can use a before filter on your route to make sure the user is logged in.
Hey,
Actually, yeh, it was the get problem. Nice one.
I already have the filter on to make sure a user can't see the page until they're logged in. However, how would I pass the logged in user's user_id to the query to replace:
->where('user_id', '1')
So basically
$course = DB:table('courses')->***Logged in User***->get();
Thanks for your help! Marc
@themarcthomas try
$courses = DB::table('courses')->where('user_id', Auth::user()->id )->get();
assuming your using laravel's auth system
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community