1

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.