Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 }] #13

Open
profprof-hub opened this issue Aug 16, 2022 · 9 comments

Comments

@profprof-hub
Copy link

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.

@TechNech
Copy link

I am facing the same issue/errors? Any fix for that? I tried Laravel Docs, stackoverflow etc.

@TechNech
Copy link

It seems to have fixed the problem when I replaced ' auth()->user()->listings()->get() ' to 'request()->user()->listings()->get()'.

@profprof-hub
Copy link
Author

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.

@profprof-hub
Copy link
Author

profprof-hub commented Oct 9, 2022 via email

@profprof-hub
Copy link
Author

profprof-hub commented Oct 9, 2022 via email

@BesimCmega
Copy link

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.

@paulrondario26
Copy link

"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

@karizmaj
Copy link

karizmaj commented Dec 17, 2023

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
]);

@profprof-hub
Copy link
Author

profprof-hub commented Dec 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants