Norway


On the Pinco.de blog there̵;s a post that covers the use of pivot models for role management in SaaS applications. The tutorial shows how to use the Laravel Eloquent "withPivot" method and a database table to create an to use relationship between "users" and "teams" in a PHP application.

If you have ever developed any kind of SaaS app (like Spark), you know what team means. Instead of picking a bad strategy for handling roles, we can bring simple solution by using Pivot .

The tutorial starts by talking about "robust permission handling" and why, more often than not, a simpler role-based approach is enough. It then covers the pivot table itself, showing the code to create the table. Next comes the creation of the relationship between teams and users via the withPivot method. With the relationship in place, the article then covers attaching users to a team, generating the models and how to add permission evaluation into the model’s functionality.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here