Dynamic Approval Package For Laravel Framework
exceptio/laravel-approval is a Laravel package for dynamic approval package for laravel framework.
It currently has 2 GitHub stars and 575 downloads on Packagist (latest version v1.0.87).
Install it with composer require exceptio/laravel-approval.
Discover more Laravel packages by exceptio
or browse all Laravel packages to compare alternatives.
Last updated
A Dynamic package for handling model based approval process in Laravel.
This package is very easy to set up. There are only couple of steps.
Pull this package in through Composer
composer require exceptio/laravel-approval
Laravel 5.5 and up
Uses package auto discovery feature, no need to edit the config/app.php file.
Laravel 5.4 and below
Add the package to your application service providers in config/app.php file.
'providers' => [
...
/**
* Third Party Service Providers...
*/
Exceptio\ApprovalPermission\ApprovalPermissionServiceProvider::class,
],
Publish the package config file to your application. Run these commands inside your terminal.
php artisan vendor:publish --provider="Exceptio\ApprovalPermission\ApprovalPermissionServiceProvider" --tag="config"
you may set approvalpermission-enable to false to disable the feature.
you may set do-migration to false in config file to disable the migration.
Note: database must have all the necessary tables and columns if you disable migration.
Publish the view file to your application. Run these commands inside your terminal.
php artisan vendor:publish --provider="Exceptio\ApprovalPermission\ApprovalPermissionServiceProvider" --tag="views"
Publish the package migration file to your application. Run these commands inside your terminal.
php artisan vendor:publish --provider="Exceptio\ApprovalPermission\ApprovalPermissionServiceProvider" --tag="migration"
Publish the package notificaiton file to your application. Run these commands inside your terminal.
php artisan vendor:publish --provider="Exceptio\ApprovalPermission\ApprovalPermissionServiceProvider" --tag="notificaiton"
Approvable trait to a class for approval process. See example below.Example Approvable Trait:
<?php
namespace App\Repositories;
use App\Models\User;
use App\Models\Member;
use Exceptio\ApprovalPermission\Approvable;
class MemberRepository
{
use Approvable;
const DRAFT_DATA = 0; // Draft member
const PENDING_DATA = 1; // Pending member
// rest of your code ...
}
This uses the default users table which is in Laravel. You should already have the migration file for the users table available and migrated.
php artisan migrate
php artisan vendor:publish --provider="Exceptio\ApprovalPermission\ApprovalPermissionServiceProvider" --tag="seeder"
composer dump-autoload
php artisan db:seed --class="ApprovalSeeder"
<?php
use App\Models\User;
use App\Models\Member;
use Exceptio\ApprovalPermission\Approvable;
class MemberRepository
{
use Approvable;
const DRAFT_DATA = 0; // Draft member
const PENDING_DATA = 1; // Pending member
public function createStepFinal(Request $request)
{
$member = new Member::create([
'name' => 'Test Member',
//so on
]);
$this->notifyApprovalCreate($member);
}
The Blade extensions.
@approvalMenu() //Show Approval menu in your application
You can change user model name, primary key and other settings in config. Have a look at config file for more information.
Before opening an issue there are a couple of considerations:
Dynamic Approval Permission For Laravel Project by Exception Solutions is marked with CC0 1.0 Universal