Nói về trường hợp mặc định về phương thức trùng với tên bảng nó sẽ quyết định id (ok)
Nếu viết
public functin owner() thì khi sử dung belongsTo(User:class) nó sẽ hiểu lấy owner_id
Do đó phải lấy theo belongsTo(User:class,"user_id");





PreviousViết lại sử dụng static thay thuộc tính \App\Address::create, $user->address()->create (ok)NextOne To Many relationship hasMany và phương thức thêm vô cùng hay (ok)
Last updated
Was this helpful?