J
J
Jedi2020-05-23 01:58:03
Laravel
Jedi, 2020-05-23 01:58:03

How to properly organize table architecture for Eloquent?

Hello!

Please give advice on how to organize tables for a bundle using Eloquent Laravel .

I'm sure I did something wrong, since I have to write SQL Query myself and use foreach to get data from another model, which is supposed to be related. hasManyThoughtwon't help either. Post

table

  • id
  • title


Content table
  • id
  • post_id (foreign)
  • video_id
  • test_id
  • article_id


There are also tables videos, tests , articles .

Content can be of three types, so I decided to do so.

video has a field that contains data on how much the video file weighs.

Can you please give me advice on how to organize this all correctly?

How, for example, would it be possible to link everything so that through the Post model I could get the total amount of memory used by this post from the videos ...

THANK YOU!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
segio_tt, 2020-05-23
@PHPjedi

Welcome to Documentation

J
jazzus, 2020-05-23
@jazzus

The contents table is not needed. Linking to videos via the ManyToMany post_video table. With the rest as well, but it is not clear why the article cannot be removed from the post and what tests are

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question