1. Go to this page and download the library: Download grazulex/laravel-statecraft 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/ */
grazulex / laravel-statecraft example snippets
use Grazulex\LaravelStatecraft\HasStateMachine;
class Order extends Model
{
use HasStateMachine;
protected $stateMachine = 'OrderStateMachine';
}
// Create a new order (starts in 'pending' state)
$order = Order::create(['total' => 100.00]);
// Transition to next state
$order->transition('pay'); // Moves to 'paid' state
// Check current state
echo $order->currentState(); // 'paid'