1. Go to this page and download the library: Download ovac/guardrails 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/ */
use OVAC\Guardrails\Concerns\Guardrail;
use OVAC\Guardrails\Services\Flow;
class Post extends Model
{
use Guardrail;
public function guardrailAttributes(): array
{
return ['published'];
}
public function guardrailApprovalDescription(array $dirty, string $event): string
{
return 'Publish flag changes
Flow::make()
->anyOfPermissions(['content.publish']) // any editor with publish permission
->
Flow::make()
->anyOfRoles(['support_lead']) // support lead approves first
->signedBy(1, 'Support Approval')
->anyOfRoles(['security_officer']) // then security approves
->signedBy(1, 'Security Approval')
->build();