Context:
I was following a tutorial about creating a page to manage listings. I've created a function to show the manage listing page and passing the data of job listings that have been created by the logged in user (currently using a user called "Test User" which have a user_id of 2). When trying to access the page, it gives me "Function () does not exist" error.
Here's the function code:
// Manage Listings
public function manage() {
// Pass 'listings'
return view('listings.manage', ['listings' => auth()->user()->listings()->get()]);
}
For some reason, in the video tutorial it worked with no issues. But in my end, the code above throws "undefined method 'listings' error. I've even copy pasted the code from github but it still gives me that error.
I've made a table called "listings" consisting of job listings created by multiple users that registered and saved in a table called "users" (See the screenshot for the structures)
"listings" table have foreign key called "user_id" which connects to the "id" from "users" table.
The use of the "user_id" foreign key is to mark the job listings so we can know the listing's creator.
Any idea how to fix this?