Level 104
May 24, 2022
1
Level 1
How to create a data that have relationship with a simple way
hello everyone, I have a question or maybe need a suggestions about how to handle creating a data using eloquent and there's a relationship. so for example, I want to created a user and then profile at the same time but I don't want make it like this
$user = User::create([
email: $request->email
.......... : $request->....
]);
// And then for profile
Profile::create([
user_id: $user->id
................. : $request->....
]);
So basically I did that for creating data that have a relationship. But is there a the other way for making this like simple? Like afterCreated I want to do something.
Thanks everyone 🙏
Please or to participate in this conversation.