ข้ามไปที่เนื้อหาหลัก

บทความ

กำลังแสดงโพสต์ที่มีป้ายกำกับ db

How to Database Relationships in Laravel10

 Type of Relationship in Database Laravel  One-to-One - One Record in the table is associated with One. For example a customer and card ID number One to Many - One record in the table is associated with multiple records.  Many to Many - Multiple records in the table are associated with multiple records. 1. One-to-One Using in-Class Model: hasOne()  Example                     $this->hasOne(Product:::class); 2. One to Many using in Class Model:  hasMany() Method Example                     $this->hasMany(Product::class); 3. Many to Many Using in-Class Model:  hasOne()  latestOfMany(), oldestOfMany() and ofMany() Example                     $this->hasOne(Product::class)->latestOfMany();                     ...