Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

3.1. Install workflow

EL OUFIR Hatim edited this page Mar 7, 2019 · 3 revisions

In this first step, you only need to use the artisan command provided by the package:

php artisan workflow:install

You can have more information about this command by executing the command php artisan workflow:install --help

Artisan command workflow:install

As you can see, the command need a single and required argument named model and can take an option named namespace.

Argument / Option Description
model This argument is the namespace of your model that you want to install the workflow system into, for example App\Project
namespace This is an optional option that you can pass to the command that means where to install the workflow history model, for example App\DAO to create the workflow history model into the folder app/DAO (by default the model will be created in the app/ folder)

Usage example

For example, we have a model Project having the structure below:

+-------------+------------------+------+-----+---------+----------------+
| Field       | Type             | Null | Key | Default | Extra          |
+-------------+------------------+------+-----+---------+----------------+
| id          | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| code        | varchar(50)      | NO   | UNI | NULL    |                |
| designation | varchar(255)     | NO   |     | NULL    |                |
| created_at  | timestamp        | YES  |     | NULL    |                |
| updated_at  | timestamp        | YES  |     | NULL    |                |
+-------------+------------------+------+-----+---------+----------------+

We will install the workflow system into this model by executing the command

php artisan workflow:install App\Project

Artisan command workflow:install

As you can see, 3 things are generated with this command:

  1. A workflow history table name workflow_history_projects has been created
    • This table will contains the workflow transitions history of the project model
  2. A new line has been created into the modules table (workflow_modules)
    • This line will tell the workflow system that the projects table is configured to take workflow transitions
  3. A model linked to the table workflow_history_projects has been created into the App\WorkflowHistoryProjects
    • Here we let the workflow install command create the model into the default path app/, but we can specify another path by specifying the --namespace=App\Custom\Namespace