Git Product home page Git Product logo

workflow-1's Introduction

Workflow (Laravel5 Package)

thanks tao2581, If you need use to laravel 4, please add

"davin-bao/workflow": "v1.0"

Workflow package provides a simple way to add audit flow to Laravel5.

Quick start

Required setup

In the require key of composer.json file add the following

"davin-bao/workflow": "dev-master"

Run the Composer update comand

$ composer update

In your config/app.php add 'DavinBao\Workflow\WorkflowServiceProvider' to the end of the $providers array

'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'DavinBao\Workflow\WorkflowServiceProvider',

),

At the end of config/app.php add 'Workflow' => 'DavinBao\Workflow\WorkflowFacade' to the $aliases array

'aliases' => array(

    'App'        => 'Illuminate\Support\Facades\App',
    'Artisan'    => 'Illuminate\Support\Facades\Artisan',
    ...
    'Workflow'       => 'DavinBao\Workflow\WorkflowFacade',

),

Configuration

Create Table

Now generate the Workflow migration

$ php artisan workflow:migration

It will generate the <timestamp>_workflow_setup_tables.php migration. You may now run it with the artisan migrate command: Open: <timestamp>_workflow_setup_tables.php change " {{ '<?php' }} " to " <?php " $ php artisan migrate

After the migration, workflow tables will be present.

Create Controllers

$ php artisan workflow:controllers

Create Routes

$ php artisan workflow:routes

Link the Model

    class Entry extends Eloquent {
      use \DavinBao\Workflow\HasFlowForResource;
    }

Add two function for audit log,Audit Flow will record this resource's title and content

		public function getLogTitle()
		{
			return $this->entry_title;
		}
		
		public function getLogContent()
		{
			return $this->entry_content;
		}

Link the Controller

		class AdminEntryController extends AdminController {
				use \DavinBao\Workflow\HasFlowForResourceController;
		}

Add roles for this controller

		Route::get('entrys/{entry}/binding', 'AdminEntrysController@getBindingFlow');
		Route::post('entrys/{entry}/binding', 'AdminEntrysController@postBindingFlow');
		Route::get('entrys/{entry}/audit', 'AdminEntrysController@getAudit');
		Route::post('entrys/{entry}/audit', 'AdminEntrysController@postAudit');

Modify config

Set the propertly values to the config/auth.php and davin-bao/workflow/src/config/config.php .

Functions

Get is binding audit flow

    if(isset($entry->isBinding)) {///is binding, do something }

Get resource audit status

    $entry->status()

Show flow Graph, show this resource audit flow status

@if(isset($entry->isBinding))
{{ Workflow::makeFlowGraph($entry->flow(), $entry->orderID()) }}
@endif

Show audit flow all details

 @if(isset($entry->isBinding))
{{ Workflow::makeAuditDetail($entry) }}
@endif

Need I audit, show audit button

    if(isset($entry->isBinding) && $entry->isMeAudit()) { /// show audit button }

workflow-1's People

Contributors

davin-bao avatar tao2581 avatar

Watchers

James Cloos avatar José Cuevas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.