alphaolomi/laravel-approvals

Laravel Approvals is a package that allows you to approve Eloquent models.

Downloads

1

Stars

3

Version

v1.0.0

Laravel Approvals

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require alphaolomi/laravel-approvals

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-approvals-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-approvals-config"

Usage

$project = Project::find(1);

// Approve a project
$project->approve('project-submitted', auth()->user());

// Check if a project is approved
$project->isApproved('project-submitted'); // true
$project->isApproved('project-submitted', auth()->user()); // true

// Check if a project is approved by a specific user
$project->isApproved('project-submitted', User::find(2)); // false

$admin = User::find(2);

// Now approve the project by an admin
$project->approve('project-approved', $admin);

// Check if a project is approved
$project->isApproved('project-approved'); // true

Using the facade

use Alphaolomi\LaravelApprovals\Facades\Approvals;

$project = Project::find(1);

// Approve a project
Approvals::approve($project, 'project-submitted', auth()->user());

// Get all approvals for a project
$allProjectApprovals = Approvals::all($project);

// Get all approvals 
$allApprovals = Approvals::allApprovals();

Testing

Project is tested with pest.

composer test

Versioning

Project follows RomVer for versioning. For the versions available, see the tags on this repository.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

alphaolomi

Author

alphaolomi