seriousjelly/laravel-draftable 问题修复 & 功能扩展

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

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

seriousjelly/laravel-draftable

Composer 安装命令:

composer require seriousjelly/laravel-draftable

包简介

A Eloquent Draftable trait for Laravel

README 文档

README

Easily add status to your models in Laravel 5.

Latest Stable Version Total Downloads Latest Unstable Version License

Installation and Requirements

  1. Install the seriousjelly/laravel-draftable package via composer:

    $ composer require seriousjelly/laravel-draftable
  2. Add the service provider (config/app.php for Laravel 5):

    # Add the service provider to the `providers` array
    'providers' => array(
        ...
        'Seriousjelly\Draftable\ServiceProvider',
    )
  3. Ensure that your migrations contain a status column by copy & pasting the below into your table migration file:

    # Add a status column to the table, feel free to change the default value.
    $table->boolean('status')->default(0);

Updating your Eloquent Models

Your models should use Draftable's trait:

use Seriousjelly\Draftable\DraftableTrait;

class MyModel extends Model
{
    use Draftable;
}

Your model is now draftable!

Using this trait

By default all records that have a status of 0 will be excluded from your query results. To include draft records, all you need to do is call the withDrafts() method on your query.

// Returns only live data
Posts::get();

//Returns live & draft data
Posts::withDrafts()->get();

Still To Do

  • Add onlyDrafts() method.
  • Add artisan command to create status column on a table you choose (i.e php artisan draftable:table table_name.
  • Allow the user to specify the column name in this package config (currently hardcoded to status).

Copyright and License

Laravel-Draftable was written by Chris Bratherton and released under the MIT License. See the LICENSE file for details.

Copyright 2015 Chris Bratherton

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固