Undefined method 'listings'. [{ "resource": "/c:/xampp/htdocs/laraf/app/Http/Controllers/ListingController.php", "owner": "_generated_diagnostic_collection_name_#1", "code": "1013", "severity": 8, "message": "Undefined method 'listings'.", "source": "intelephense", "startLineNumber": 98, "startColumn": 11, "endLineNumber": 98, "endColumn": 19 }]
Opened this issue · 9 comments
i am having issue with this line of code "return view('listings.manage', ['listings' => auth()->user()->listings()->get()]);". i try replacing it with the one on github but it still not working.
I am facing the same issue/errors? Any fix for that? I tried Laravel Docs, stackoverflow etc.
It seems to have fixed the problem when I replaced ' auth()->user()->listings()->get() ' to 'request()->user()->listings()->get()'.
I have solved that issue by changing the access modifier of the listings() method from protected function listings (){
return $this->hasMany(Listing::class, 'user_id');
} to public function listings (){ return $this->hasMany (Listing::class, 'user_id'); } in the User Model.
I have solved that issue by changing the access modifier of the listings() method from protected function listings (){ return $this->hasMany(Listing::class, 'user_id'); } to public function listings (){ return $this->hasMany (Listing::class, 'user_id'); } in the User Model.
Where exactly? I have the modifier public and it's still not working.
"severity": 8,
"message": "Undefined method 'listings'.",
"source": "intelephense",
"startLineNumber": 99,
"startColumn": 67,
"endLineNumber": 99,
"endColumn": 75
Even if public function listings() is in User table the listings() method shows as undefined in listingcontroller.php
Undefined method 'listings'.intelephense(P1013):
Seems like the plugin is just not recognizing the function, but it still works fine.
I just ignored it.
/** @disregard */
return view('listings.manage', [
'listings' => auth()->user()->listings()->paginate() //intelephense marks this as an error but it works
]);