承接 codewithtony/laravel-active-attribute 相关项目开发

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

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

codewithtony/laravel-active-attribute

Composer 安装命令:

composer require codewithtony/laravel-active-attribute

包简介

Laravel Active Attribute

README 文档

README

Laravel Active Attribute adds withInactive and onlyInactive functionality to an Eloquent Model.

This can be used to automatically hide inactive records unless otherwise desired. A better solution might be the use Soft Deletes but there are a number of reasons why you might want to use an active field.

This can also serve as a good example of how to do similar things to use Scopes and Macros in Laravel to manipulate queries at a higher level.

Install

composer require codewithtony/laravel-active-attribute

Usage

Add the HasActiveAttribute to any Eloquent Model that has an ->active field that is a 1/0 boolean

class Thing 
{
    Use HasActiveAttribute;
    ...
}

After that you can use it as follows

Thing::all(); // only records where $model->active = 1
// or
Thing::withInactive()->all(); // records where $model->active = 1 OR 0
// or
Thing::onlyInactive()->all(); // only records where $model->active = 0

Customize Active Feild

By default active is the default field that this will look at, to customize it you can set the constant ACTIVE. For example, if the field is named is_active.

class Thing 
{
    const ACTIVE = 'is_active';
    Use HasActiveAttribute;
    ...
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固