1. Go to this page and download the library: Download dev-bumba/laraflow 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 LaraFlow\Traits\HasStateHistory;
use Spatie\ModelStates\HasStates;
class Reclamacao extends Model
{
use HasStates, HasStateHistory;
protected function registerStates(): void
{
$this->addState('status', ReclamacaoStatus::class)
->transitionTo(Rececionada::class, GenericTransition::class);
}
}
$reclamacao->status->transitionTo(Rececionada::class, [
'roles' => ['analista-compliance'],
'payload' => [
'complaint_id' => $reclamacao->id,
'user_id' => auth()->id(),
'parecer' => 'Análise concluída com base nos termos regulatórios vigentes.',
]
]);
text
app/States/Complaint/
├── ComplaintStatus.php # Classe principal da Máquina de Estados
├── Guards/
│ └── ValidarComplaint.php # Guard de validação de regras de negócio
└── Actions/
└── ExecutarAcaoComplaint.php # Action de efeito colateral pós-transição
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.