Skip to content

Tag: eloquent

hasManyThrough – Laravel 5.8

I have database table structure like : ClassRoom id (int) PK name (varchar) ClassTeacherCourse id (int) PK id_classroom (int) FK id_teacher (int) FK id_course (int) FK Course id (int) PK course_name (varchar) Teacher id (int) PK teacher_name (varchar) So far I have code just to call ClassRoom table & Clas…

Laravel relation from a pivot

I have a relation that I cant figure out my current application looks like this Models Tables Now a tournament can have just some of the users participate in the tournament so I’ve created the below To store users that are participating in a tournament from the team. How should this look in terms of elo…

How to join relationships in Eloquent?

I’m stuck in a problem, I have these 3 models: Order, OrderItem and Product, each Order has many Order Items, and each Order Item has one Prduct but a Product can be ordered several times. Product has a supplier ID column (each supplier has many Products). So here are the relationships: Model: Order: Mo…