wowe/laravel-eloquent-scopes 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wowe/laravel-eloquent-scopes

最新稳定版本:v3.0.0

Composer 安装命令:

composer require wowe/laravel-eloquent-scopes

包简介

Some general scopes for Eloquent

README 文档

README

This package includes some useful global scopes for Laravel Eloquent.

Installation
Traits
Usage
Release Notes
Version Compatibility
License

Installation

Via Composer

composer require wowe/laravel-eloquent-scopes

Traits

ActivatableTrait

When this trait is added to an Eloquent model, it will only return rows which have the active field set to true.

If you want to use a field with a different name than active, set a constant called ACTIVE on the Eloquent model to whichever name you would like to use.

The following methods are included with the trait:

  • deactivate: sets the active field to false.
  • activate: sets the active field to true.
  • withInactive: will include all entries in results regardless of the value of the active field.
  • onlyInactive: will include only those entries with active fields set to false.

Usage

Add Trait to Model

Add the ActivatableTrait to an Eloquent model.

use Wowe\Eloquent\Scopes\ActivatableTrait;

class Test extends \Eloquent
{
    use ActivatableTrait;

    const ACTIVE = 'is_active';
}

Query Model

// Get all entries that are active
Test::all();

// Get a single entry only if active
Test::find(1);

// Get all entries
Test::withInactive()->get();

// Get all inactive entries
Test::inactiveOnly()->get();

Version Compatibility

This Package Laravel
1.x.x 4.2.x
2.x.x 5.0.x
3.x.x 5.1.x

License

This package is open-sourced software licensed under the MIT license

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-02