Skip to content
Advertisement

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 & ClassTeacherCourse, like : Relationship in Class Model : Result : I

Laravel Many-to-Many Factory with custom id type

I am using Laravel 8 and trying to make database factories/seeders I am having some issues. I have the following database Schema: Now I am trying to create factories and database seeders but I get an error using the following line to seed: This gives me the following error: Which is if I understand it correctly because an isbn number

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 eloquent relations? Answer So taking

Laravel – Name from foreign key doesn’t show in my blade

I’m making a project where I use the foreign key from a shop in products. The foreign key works but when I want to show it in my blade by using $product->shop_id->shop_name, it gives a blank spot. My foreign key is named ‘shop_id’.Product page without shop name This is my code: ProductController: product.blade.php Product Model Shop model Answer Your provided

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: Model OrderItem Model Product What I want

Advertisement