Reputation: 107
I'm building an application and I'm new to Laravel.
In this application, there are 3 kinds of users that interact with it: user1, user2,user3
user3 must related to one of user2
is it possible to do like :
user : id , name , is_related_to_another , user_id
for user1 : 1 , Ali , 0 , Null
for user2 : 2 , AA , 0 , Null
for user3 : 3 , AAA , 1 , 2
is it correct ? any suggestion
Upvotes: 1
Views: 55
Reputation: 54
Yes, that is possible. Instead of explicitly saying is_related_to_another
, you can assume the relationship state based on whether a user_id
is set.
Make sure to look at the Eloquent relationship documentation from Laravel, you will get an in depth explanation of how to make this work.
Upvotes: 2