承接 mathewparet/requires-publishing 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mathewparet/requires-publishing

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mathewparet/requires-publishing

包简介

Add record publishing unpublishing features to a model.

README 文档

README

Provide the ability to models to be published.

Features

  1. Publish / Unpublish a model.
  2. Published models are not considered for any queries by default (adds a global scope).

Installation

composer require mathewparet/requires-publishing

Defining a field to hold publish status in migrations

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

or

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

Add the funtionality to your model

// ...
use mathewparet\RequiresPublishing\RequiresPublishing;
// ...
class User extends Authenticatable
{
    // ...
    use RequiresPublishing;
    // ...

    /**
     * To use custom field name for publishing, use the below line. If the below line isn't 
     * defined, the field is assumed to be 'published_at'.
     */
    const PUBLISHED_AT = 'active_at';
}

API referance

This package introduces the below methods:

NameAvailabilityDescription
requiresPublishing()BlueprintMacro to define a field that holds the publish state for the record.
publish()ModelMark a model as published.
publishQuetly()ModelMark a model as published without raising any events.
unpublish()Model, BuilderMark a model as unpublished.
unpublishQuetly()ModelMark a model as unpublished without raising any events.
withUnpublished()ModelAdd unpublished records to the scope.
withoutUnpublished()ModelRemove unpublished records from scope.
onlyUnpublished()ModelScope the query to only consider unpublished records.

Events

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

统计信息

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

GitHub 信息

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

其他信息

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