定制 mathewparet/model-suspension 二次开发

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

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

mathewparet/model-suspension

最新稳定版本:v1.0.9

Composer 安装命令:

composer require mathewparet/model-suspension

包简介

Add record suspension (like user suspension) and unsuspension features to a model.

README 文档

README

Provide the ability to models to be suspended.

Features

  1. Suspend / Unsuspend a model.
  2. Suspended models are not considered for any queries by default (adds a global scope).

Installation

composer require mathewparet/model-suspension

Defining a field to hold suspension status in migrations

// define a 'suspended_at' field of type dateTime and is nullable
$table->canBeSuspended();

or

// define a 'flagged_at' field of type dateTime and is nullable
$table->canBeSuspended('flagged_at');

Add the funtionality to your model

// ...
use mathewparet\ModelSuspension\CanBeSuspended;
// ...
class User extends Authenticatable
{
    // ...
    use CanBeSuspended;
    // ...

    /**
     * To use custom field name for suspension, use the below line. If the below line isn't 
     * defined, the field is assumed to be 'suspended_at'.
     */
    const SUSPENDED_AT = 'flagged_at';
}

API referance

This package introduces the below methods:

NameAvailabilityDescription
canBeSuspended()BlueprintMacro to define a field that holds the suspension state for the record.
suspend()ModelMark a model as suspended.
suspendQuetly()ModelMark a model as suspended without raising any events.
unsuspend()Model, BuilderMark a model as unsuspended.
unsuspendQuetly()ModelMark a model as unsuspended without raising any events.
withSuspended()ModelAdd suspended records to the scope.
withoutSuspended()ModelRemove suspended records from scope.
onlySuspended()ModelScope the query to only consider suspended records.

Events

  1. suspending
  2. suspneded
  3. unsuspending
  4. unsuspended

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-03