Back

Hey Laravel Developers

Laravel provides us with the belongsToMany() relationship, allowing us to form many-to-many relationships between two different models in our application.

An example of this relationship is the User and Role model where one Role can belong to many users and one user can belong to many roles.

We create an intermediate/pivot table to map the relationships between these two models.

But do you know that you can also maintain timestamps for when these relationships were formed, by using the withTimestamp() method while creating the relationship?

image

37

  • No matching results...
  • Searching...

/ 1000