PHP code example of bidzm / eloquent-state-machine

1. Go to this page and download the library: Download bidzm/eloquent-state-machine 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/ */

    

bidzm / eloquent-state-machine example snippets




public function beforeTransition($from, $to)
{
    // do something
}

public function afterTransition($from, $to)
{
    // do something
}



$message = new App\Message();
$message->save();
$message->state; // `initiated`
$message->initiatedAt(); // 2017-08-19T21:07:00+07:00

$message->queue();
$message->state; // `queued`
$message->initiatedAt(); // 2017-08-19T21:07:00+07:00
$message->queuedAt(); // 2017-08-19T21:07:01+07:00