php - Laravel Eloquent Model adequate to Database Model -


I have a MySQL DB table on display and code organization in my web application: The user (id, un, pass), author (ID, signature ...), reader (id, description), where users The ID column corresponds to the ID in both tables. This DB model comes from ER model, where user is a super class of both of them in my app Author or Reader to To get data from the user , then my first question is, can I do some sort of succession to make this effortlessly in a well-known model?

My current setup is that I create two views: the author joins ( user and author ) and readers ( gets < / Strong> users and reader ) and I plan to use them with lectures with WHERE sections, is it bad for performance? I know that MySQL uses merge algorithms, so those questions will be translated into an SQL command, but if someone has a proposal then what is the best way to do so, please answer. Thanks!

You have to set ER in both models.

As an example, your User.php model should be a method called

  class user IO Eloquent {... // User has authored a public function author () {return $ this-> Hayon ('authors'); } ...}  

In your author.php model, you

  class user eloquent extended {... public function user () {return $ this - & gt; Retail ('user', 'id'); } ...  

This is for the Reader.php model.

You can take a look at;)


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -