alphaolomi / laravel-approvals
Laravel Approvals is a package that allows you to approve Eloquent models.
v1.0.0
2023-07-15 22:19 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-10-26 04:02:38 UTC
README
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.