Courses

How to Structure Databases in Laravel

BelongsTo, BelongsToMany or Polymorphic? Three Examples.

avatar

The Tags relation seems to be the same as the Photos in that you could add more content types that would have tags (podcast, book, etc), and polymorphic would remove the need to modify the model (consistent with the open-closed principle from your other course :). After watching this I read the Laravel docs on polymorphic many-to-many and it seemed clear enough.

👍 1
avatar

Thanks))

avatar

Hi Povilas,

I have doubts on creating relationship for this situation.

User has a role ( Front team, Backend team, Manager , Admin )

If user is Front or backend, then they should have any Manager,

i created table like structure Manager_relation user_id, manager_id (userid), type (backend / frontend)

What kind of this relation this ? Is there any other betterway to handlet this ?

Thank you.

avatar

There's no easy and quick way to answer this, it depends on what other operations you will perform with those users, areas and managers. In your case, it's a pivot table with additional column, which looks fine.

avatar

Hi Povilas, you mentioned that there is a rule of naming convention in laravel. I've found some of them on laravel.com but, is there any document with all these rules? I'm really interested in getting a better understanding of these rules, especially those related to variables and model properties.

Thank you.

avatar

No, we have not seen a good document with the naming conventions in them. They are just there, but as always - you can go and create whatever you want yourself :)