Download the PHP package iben12/laravel-statable without Composer

On this page you can find all versions of the php package iben12/laravel-statable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-statable

Statable trait for Laravel Eloquent models

Run tests StyleCI Scrutinizer Code Quality

This trait provides drop-in functionality to manage state and state history of an existing Eloquent Model based on winzou/state-machine using sebdesign/laravel-state-machine service provider.

Installation

Compatibility:

Version Upstream Laravel PHP
v0.1 sebdesign/laravel-state-machine:^1.3 < 5.5
v1.3 sebdesign/laravel-state-machine:^2.0 >= 5.5
v1.4 sebdesign/laravel-state-machine:^3.0 >= 7.0 >= 7.3
v1.5 sebdesign/laravel-state-machine:^3.2 >= 7.0 >= 8.0

So if you are below Laravel 5.5, require 0.1 version explicitly. For Laravel below 7 require version v1.3.

Use composer to pull in the package:

Publish the database migration and state machine config:

Migrate the database:

This migration creates the table for storing history of your models as a polymorphic relation.

Usage

Prerequisites

Setup

For this manual we will use a Post model as example.

First you configure the SM graph. Open config/state-machine.php and define a new graph:

Now you have to edit the Post model:

And that's it!

Usage

You can now access the following methods on your model:

NOTE: The history saves the currently authenticated user, when applying a transition. This makes sense in most cases, but if you do not use the default Laravel authentication you can override the getActorId method to store the user with the history.

If the model is newly created (never been saved), so it does not have an id when applying a transition, history will not be saved. If you want to be sure that all transitions are saved in history, you can add this method to your model:

State machine

sebdesign/laravel-state-machine provides a lot of features:

You can find the documentation in the repo.

If you want to interact directly with the StateMachine object of your model, call $model->stateMachine().

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-statable with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
sebdesign/laravel-state-machine Version ^3.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iben12/laravel-statable contains the following files

Loading the files please wait ....