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"
$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();
Project is tested with pest.
composer test
Project follows RomVer for versioning. For the versions available, see the tags on this repository.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.