Viết lại sử dụng static thay thuộc tính \App\Address::create, $user->address()->create (ok)

https://app.gitbook.com/@c-i-ph-n-m-m-tr-n-ubuntu-c-n-thi/s/learn-lavarel/relationships-su-dung-hasone-ok

$user  = factory(\App\User::class)->create();
// Cách 1:
	\App\Address::create([
		"user_id" => $user->id,
		"country" => "Ha Nam 10"
	]);
// Cách 2:
// $user->address()->create([
// 	"country" => "Ha Nam 9"
// ]);

Last updated