Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Pineco.de:
Easy Role Management with Pivot Models
Feb 13, 2018 @ 16:41:32

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 pivot database table to create an easy 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 level role management means. Instead of picking a bad strategy for handling roles, we can bring simple solution by using Pivot Models.

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.

tagged: role management pivot model tutorial laravel eloquent

Link: https://pineco.de/easy-role-management-pivot-models/


Trending Topics: