2017 © Pedro Peláez
 

library laravel-model-ext-trait

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

image

five-say/laravel-model-ext-trait

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  • Sunday, August 21, 2016
  • by 5-say
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

laravel-model-ext-trait

基于 trait 的 laravel 模型特性拓展:[ packagist ], (*1)

  • 自动注册模型观察者(注册 Observer 命名空间下,与当前模型同名的模型观察者)
  • 创建与更新数据前,自动校验请求数据

创建新数据时,对所有规则进行验证。
更新数据时,仅针对脏数据进行验证。(从根本上避免类似于 unique 这种特殊规则在编辑时遇到的“需额外参数以排除自身”的问题), (*2)

安装

    composer require five-say/laravel-model-ext-trait

使用

<?php

use FiveSay\Laravel\Model\ExtTrait;

class User
{
    use ExtTrait;

    /**
     * 数据校验规则
     * @var array
     */
    public $rules = [
        'name' => [
            'required' => '请填写用户名',
        ],
        'email' => [
            'required'     => '请填写 email',
            'email'        => 'email 格式不正确',
            'unique:users' => 'email 已被占用',
        ],
    ];


}

The Versions

21/08 2016

dev-master

9999999-dev

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

27/04 2016

v1.1.1

1.1.1.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

15/04 2016

v1.1.0

1.1.0.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

18/03 2016

v1.0.5

1.0.5.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

28/02 2016

v1.0.4

1.0.4.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

28/01 2016

v1.0.3

1.0.3.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

21/01 2016

v1.0.2

1.0.2.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

21/01 2016

v1.0.1

1.0.1.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer

14/01 2016

v1.0.0

1.0.0.0

基于 trait 的 laravel 模型特性拓展:自动注册模型观察者;创建与更新数据前,自动校验请求数据。

  Sources   Download

The Requires

 

by FiveSay

model validate observer