iutrace/laravel-abilities

Easily add abilities business logic to your models

v0.2.0 2021-10-30 22:39 UTC

This package is auto-updated.

Last update: 2024-06-05 02:52:30 UTC


README

A convenient way to encapsulate model conditions business logic

Laravel Gates are an excellent way to separate logic of access and permissions from models, but if we need to separate only models conditions not related to users (ex: if is valid to Publish a Post at certain state regardless of user)

This package adds a layer on top of laravel Gates, so first "ability" validity is checked then user access and permission is checked though normal laravel Gates if present.

Also, this package adds abilities and policies attributes to your models through HasHabilities trait, useful if you need available "actions" at frontend.

Installation

$ composer require iutrace/laravel-abilities

Usage