1. Go to this page and download the library: Download dbflowlabs/core 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 DbflowLabs\Core\Contracts\Workflowable;
use DbflowLabs\Core\Traits\HasWorkflow;
final class RefundRequest extends Model implements Workflowable
{
use HasWorkflow;
public function workflowBusinessKey(): ?string
{
return $this->reference_no;
}
public function workflowDisplayName(): string
{
return 'Refund Request';
}
}
use DbflowLabs\Core\Contracts\WorkflowContextInterface;
public function getWorkflowVariables(): array
{
return [
'total_amount' => (float) $this->amount,
'supplier_type' => $this->supplier_type,
];
}
$instance = $refundRequest->startWorkflow('refund_approval');
// equivalent to DBFlow::start('refund_approval', $refundRequest, auth()->user());
use DbflowLabs\Core\DBFlow;
$instance = DBFlow::start(
'refund_approval',
$refundRequest,
auth()->user(),
[
// Host-defined keys — stored as JSON on dbflow_workflow_instances.metadata
'submit_comment' => 'Q2 budget exception',
// Used for condition routing when the model does not implement WorkflowContextInterface
'variables' => ['priority' => 'high'],
],
);
// Register the resolver key used above
DBFlow::registerAssigneeResolver(
app(AssigneeResolverRegistry::class),
'approve_refunds',
new ApproveRefundsAssigneeResolver(),
);
// Does NOT auto-resolve Laravel / Spatie permissions
'assignees' => ['type' => 'permission', 'value' => 'approve-refunds'],