1. Go to this page and download the library: Download fproject/workflowii 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/ */
/**
* @property integer $id
* @property string $title
* @property string $body
* @property string $status column used to store the status of the article
*/
class Article extends \yii\db\ActiveRecord
{
public function behaviors()
{
return [
\fproject\workflow\core\ActiveWorkflowBehavior::className()
];
}
// ...
$article = new Article();
$article->status = 'draft';
$article->save();
echo 'article status now is : '. $article->workflowStatus->label;
$article = new Article();
$article->sendToStatus('draft'); // OK
$article->sendToStatus('deleted'); // OK
$article->sendToStatus('published'); // Error!