PHP code example of alphaolomi / laravel-approvals
1. Go to this page and download the library: Download alphaolomi/laravel-approvals library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alphaolomi / laravel-approvals example snippets
$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
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();