Method should not be called statically.... Can someone please put something to bed for me. I see this error message a lot:
"Non-static method 'find' should not be called statically less... (⌃F1)
Dynamic class method called as static."
However what I'm trying to do works.
Here is one example of where this error flags up:
$meal = Meal::find($meal_id);
$mealname = $meal->meal_name;
The above works just fine. But that error is screaming at me.
Thanks
with this?
$meal = Meal::where('id', $meal_id)->firstOrFail();
I can see that your solution would work, but I was asking why mine is "wrong"?
I use the quote marks around "wrong" because although my IDE is screaming at me, it works just fine.
Thanks for taking the time to answer.
Hi thanks for that, it still doesn't work but at least I now know that I'm not mad, and that many many others are frustrated by the same issue.
It also happens for a lot of laravels "magic" methods that IDE's can't figure out bc the methods don't actually exist, but they get called via php's magic __get() method.
Things like Model::whereName('some-name') cause issues instead of Model::where('name', 'some-name'), because there isn't an actual whereName method but there is a where method.
It is annoying, so I don't use any of them.
@Cronix at some point I'll go through and refactor, because it does genuinely annoy me. However right now I just need to get shit out of the door :-)
Its just a phpstorm thing ?
@Snapey Yeah just a PHPStorm thing.
Please sign in or create an account to participate in this conversation.