Requires https://github.com/yohang/Finite
<?php
class StatefulModel extends Model
{
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>jQuery UI Sortable - Default functionality</title> | |
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> | |
| <link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> | |
| <style> | |
| body { |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <phpunit backupGlobals="false" | |
| backupStaticAttributes="false" | |
| bootstrap="bootstrap/autoload.php" | |
| colors="true" | |
| convertErrorsToExceptions="true" | |
| convertNoticesToExceptions="true" | |
| convertWarningsToExceptions="true" | |
| processIsolation="false" | |
| stopOnFailure="false"> |
| 'mysql-local' => [ | |
| 'driver' => 'mysql', | |
| 'host' => env('DB_HOST', 'localhost') . ('homestead' == gethostname() ? null : ':33060'), | |
| 'port' => env('DB_PORT', '3306'), | |
| 'database' => env('DB_DATABASE', 'forge'), | |
| 'username' => env('DB_USERNAME', 'forge'), | |
| 'password' => env('DB_PASSWORD', ''), | |
| 'charset' => 'utf8', | |
| 'collation' => 'utf8_unicode_ci', | |
| 'prefix' => '', |
Requires https://github.com/yohang/Finite
<?php
class StatefulModel extends Model
{
| <?php namespace App\Finite; | |
| /** | |
| * The FiniteAuditTrail Trait. | |
| * This plugin, for the Finite package (see https://github.com/yohang/Finite), adds support for keeping an audit trail for any state machine. | |
| * Having an audit trail gives you a complete history of the state changes in your stateful model. | |
| * Prerequisites: | |
| * 1. Install Finite package (https://github.com/yohang/Finite#readme) | |
| * 2. Use FiniteStateMachine in your model (https://gist.github.com/tortuetorche/6365575) | |
| * Usage: in your Stateful Class use this trait after FiniteStateMachine trait, like this "use FiniteAuditTrailTrait;". |
Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.
In your Stateful Class, add the stateMachineConfig() method and call initStateMachine() method at initialization (__contruct() method).
Example
| <?php | |
| use Illuminate\Foundation\Testing\ApplicationTrait; | |
| use Illuminate\Foundation\Testing\AssertionsTrait; | |
| use Illuminate\Support\Facades\Artisan; | |
| trait LaravelTrait | |
| { | |
| /** |
| <?php | |
| use Illuminate\Foundation\Testing\ApplicationTrait; | |
| use Illuminate\Foundation\Testing\AssertionsTrait; | |
| use Illuminate\Foundation\Testing\CrawlerTrait; | |
| use Illuminate\Support\Facades\Artisan; | |
| trait LaravelTrait | |
| { |
| <?php | |
| trait PhpUnitAssertionsTrait | |
| { | |
| /** | |
| * Asserts that an array has a specified key. | |
| * | |
| * @param mixed $key | |
| * @param array|ArrayAccess $array |