daniel-de-wit/laravel-model-active 问题修复 & 功能扩展

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

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

daniel-de-wit/laravel-model-active

Composer 安装命令:

composer require daniel-de-wit/laravel-model-active

包简介

Simple trait for scoping Eloquent models by 'active' boolean

README 文档

README

A trait for Laravel to only pull models marked as "active". When the trait is applied to a model, the queries will, by default, only find rows for that model where the active column has a value of 1.

Requirements

  • Laravel ^5.2

Installation

Add package to composer.json

composer require daniel-de-wit/laravel-model-active

Usage

Add active boolean to Eloquent Model:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddActiveModelSupportToArticleTable extends Migration
{
    public function up()
    {
        Schema::create('article', function (Blueprint $table) {
            $table->boolean('active')->default(true)->index();
        });
    }
    
    public function down()
    {
        Schema::table('article', function (Blueprint $table) {
            $table->dropColumn('active');
        });
    }
}

Add the Active trait to the model:

<?php

class MyModel extends Eloquent
{
    use Active;

    ...

}

Removing Active Scope

If you would like to remove the active scope for a given query, you may use the withoutGlobalScope method:

<?php

    MyModel::withoutGlobalScope(ActiveScope::class)->get();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固