Skip to content
Advertisement

Tag: eloquent

find() does not get the existing row

I have a resource Controller with this index method like this: But it returns this error: Trying to get property ‘slug’ of non-object And when I dd(Category::find(25), Category::find(24), Category::find(23), Category::find(22)); I get NULL results. Meaning that it can not find data with specified ids. However there are 25 records stored at the categories table: So what is going wrong here?

SQLSTATE[HY000]: General error: 1005 Can’t create table `school`.`posts` (errno: 150 “Foreign key constraint is incorrectly formed”)

before everything, I tried hard many websites and forums to solve this problem until these posts related to this problem in StackOverflow, but I can’t solve the problem. I want to create to one to many relationship between Post and Category model but I get that error code. SQLSTATE[HY000]: General error: 1005 Can’t create table school.posts (errno: 150 “Foreign key

Eloquent “where” on relationship returns wrong models

I have this method on my model “Employer”: I thought it would work fine, but it ends up giving me models that aren’t even related to my Model. Like, the id of the model is 37 and it gives me the relationships of all the models (like id 6). Any idea of why this would happen? Answer I think you

Advertisement