1. Go to this page and download the library: Download raoul2000/yii2-workflow 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/ */
namespace app\models;
/**
* @property integer $id
* @property string $title
* @property string $body
* @property string $status column used to store the status of the post
*/
class Post extends \yii\db\ActiveRecord
{
public function behaviors()
{
return [
\raoul2000\workflow\base\SimpleWorkflowBehavior::className()
];
}
// ...
$post = new Post();
$post->status = 'draft';
$post->save();
echo 'post status is : '. $post->workflowStatus->label;
$post = new Post();
$post->sendToStatus('draft');
$post->sendToStatus('deleted');
$post->sendToStatus('publish'); // danger zone !
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.