am2studio/laravel-finite

Service provider for finite
5,092 2
Install
composer require am2studio/laravel-finite
License:MIT
Last Updated:Nov 15, 2022
Links: GitHub  ·  Packagist
Maintainer: msamec

Laravel-Finite

Latest Version on Packagist Software License Total Downloads

Install

Via Composer

$ composer require AM2studio/Laravel-Finite

in config/app.php

under 'providers' add

AM2Studio\LaravelFinite\LaravelFiniteServiceProvider::class,

under 'alias' add

'Finite'    => AM2Studio\LaravelFinite\FiniteFacade::class,

publish migration files and run migration

php artisan vendor:publish --provider="AM2Studio\LaravelFinite\LaravelFiniteServiceProvider" --tag="migrations"
php artisan migrate

Usage

In models you want to use it add namespace

use AM2Studio\LaravelFinite\Traits\LaravelFiniteTrait;

and then use trait

use LaravelFiniteTrait;
Finite::can($eloquentModelObject, 'finite transition');
Finite::apply($eloquentModelObject, 'finite transition');
Finite::getName($eloquentModelObject));

It is recommended that you use Relation::morphTo([]) because that way if you change the namespace of your model the records in DB won't break.

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Credits

License

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