PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] how to write many to many with 3 core table in laravel?

 April 14, 2022     laravel, migration, model     No comments   

Issue

I have class tables and lessons (many to many).

if the user can have many classes and many lessons. what is a user (many to many) with classes. then the user (many to many) with lessons?

how to get values ​​like: George, 12th grade Senior High School, mathematics. ? (username, class_name, and lesson_name). in blade or controller.

please correct me if i wrong, im new in programming Thanks a lot


Solution

can i do it like this?

I made it into 4 tables. 1 tb_user, 2 tb_class, 3 tb_lesson, and 4 tb_details.

tb_user hasMany tb_detail tb_detail belongsTo tb_class tb_detail belongs To tb_ lesson

with that i hope i can get data like in my question with accessing the tb_detail. please correct me if i wrong. im new in programming



Answered By - Febri Tahta
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing