david19
9 months ago
500
2
Laravel

doesntHave Query

Posted 9 months ago by david19

Hello Team.

I have a categorie Table with unlimted Subcategories

Id### Name###Parentid
1 ### Car ### Null
2 ###Bmw### 1
3 ###Ford###  1

When i go to my "EDIT" Page, i can choose my parent category. But the problem is, when i go to the "Ford" Edit Page, i can set "Ford" as Parent. But this is not correct. Ford can not a parent of Ford. Now i try to fix this, but i can not fix this. I need all categories which as not the "ID", which i edit. This is what i try now:

$category = category::find($id);
$categories = category::doesntHave('????')->get();

Please sign in or create an account to participate in this conversation.