定制 asz/statemm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asz/statemm

Composer 安装命令:

composer require asz/statemm

包简介

manage model state

README 文档

README

Overview

  • This is a Laravel package to manage model state

Installation :

You can install asz/statemm via Composer by adding " asz/statemm": "^1.1" as requirement to your composer.json. OR :

composer require asz/statemm
  • Then :
composer dump-autoload

Service Provider:

go to your config/app.php file and add :

 statemm\StateServiceProvider::class ,

adding interface to model

class Product extends Model implements hasState

use command line to create a new state for your model

$ php artisan state:make activated --dir=productStateContainer
add method stubs in your model:
 public function initialState()
    {
         //set your initial state after generated 
        // TODO: Implement initialState() method.
        
        return new ActivatedState();
    }

Test Unit

    public function testCanDeactivateProduct()
    {

        $product = new product();
       
       // the product is active and the initial state will check to 
       // $this->transitionTo( new DeactivatedState()); 
       
        $context = new Context($product->where(['id' => 4])->first()); 
       
       // if true the proceed function will go to next state 
       // which is deactivatedState and execute the query or what 
       // you want todo
       // the deactivated has query to deactivate the given product
       
       $context->proceed();
       self::assertEquals(StateEnum::DEACTIVATED_STATE, $context->getModel()->state);
    }
    
    ```

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固