laravel-validable:Laravel特征可在保存时自动验证模型

  • k8_207384
    了解作者
  • 31.2KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 09:44
    上传日期
保存Eloquent模型时激活激活验证的特性 该软件包提供了一个特征,当使用上载表单请求保存/更新/删除任何口才模型时,该特征将自动阻止上载。 ##要求 PHP:> = 7.0.0 照亮/数据库:^ 5.0 照明/支撑:^ 5.0 照明/验证:^ 5.0 安装 您可以通过composer安装该软件包: $ composer require padosoft/laravel-validable 用法 您的Padosoft\Laravel\Validable\Validable模型应使用Padosoft\Laravel\Validable\Validable特征。 您必须在模型中定义protected static $rules数组。 您可以在模型中定义protected static $messages的自定义消息的protected static $messages数组。
laravel-validable-master.zip
  • laravel-validable-master
  • composer.json
    1.1KB
  • composer.lock
    227.4KB
  • CONDUCT.md
    2.1KB
  • CONTRIBUTING.md
    2.9KB
  • src
  • Validable.php
    3.4KB
  • LICENSE.md
    1.1KB
  • CHANGELOG.md
    536B
  • README.md
    3.7KB
  • .editorconfig
    312B
内容介绍
# Trait to activate validation when saving Eloquent Model [![Latest Version on Packagist](https://img.shields.io/packagist/v/padosoft/laravel-validable.svg?style=flat-square)](https://packagist.org/packages/padosoft/laravel-validable) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) [![Build Status](https://img.shields.io/travis/padosoft/laravel-validable/master.svg?style=flat-square)](https://travis-ci.org/padosoft/laravel-validable) [![Quality Score](https://img.shields.io/scrutinizer/g/padosoft/laravel-validable.svg?style=flat-square)](https://scrutinizer-ci.com/g/padosoft/laravel-validable) [![Total Downloads](https://img.shields.io/packagist/dt/padosoft/laravel-validable.svg?style=flat-square)](https://packagist.org/packages/padosoft/laravel-validable) [![SensioLabsInsight](https://img.shields.io/sensiolabs/i/4570b2c7-71c6-4b11-9214-da078fb51a98.svg?style=flat-square)](https://insight.sensiolabs.com/projects/4570b2c7-71c6-4b11-9214-da078fb51a98) This package provides a trait that will automatic handlind upload when saving/updating/deleting any Eloquent model with upload form request. ##Requires - php: >=7.0.0 - illuminate/database: ^5.0 - illuminate/support: ^5.0 - illuminate/validation: ^5.0 ## Installation You can install the package via composer: ``` bash $ composer require padosoft/laravel-validable ``` ## Usage Your Eloquent models should use the `Padosoft\Laravel\Validable\Validable` trait. You must define `protected static $rules` array of rules in your model. You can define `protected static $messages` array of custom messages in your model. Here's an example of how to implement the trait; ```php <?php namespace App; use Padosoft\Laravel\Validable\Validable; use Illuminate\Database\Eloquent\Model; class YourEloquentModel extends Model { use Validable; protected static $rules = [ 'name'=>'required|max:10', 'order'=>'sometimes|integer|max:10', ]; protected static $messages = [ 'name.required'=>'obbligatorio' ]; } ``` You can write specific validation for only update method ```php class YourEloquentModel extends Model { use Validable; protected static $rules = [ 'name'=>'required|max:10|unique:table,field', 'order'=>'sometimes|integer|max:10', ]; protected static $updating_rules = [ 'name'=>'required|max:10|unique:table,field,[id]', 'order'=>'sometimes|integer|max:10', ]; protected static $messages = [ 'name.required'=>'obbligatorio' ]; } ``` **Note:** [id] will be overwritten at runtime with the model property. You can check if your model is saved like this: ```php $model = new YourEloquentModel; $model->name='test'; if (!$model->save()){ $erros=$model->getErrors(); } ``` You can get a model validation rules: ```php $rules=YourEloquentModel::getRules(); ``` For all method available see the Validable Trait. ## Change log Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. ## Testing ``` bash $ composer test ``` ## Contributing Please see [CONTRIBUTING](CONTRIBUTING.md) for details. ## Security If you discover any security related issues, please email instead of using the issue tracker. ## Credits Inspired by https://github.com/JeffreyWay/Laravel-Model-Validation - [Lorenzo Padovani](https://github.com/lopadova) - [Leonardo Padovani](https://github.com/leopado) - [All Contributors](../../contributors) ## About Padosoft Padosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites. ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
评论
    相关推荐
    • yii2-chartjs-widget:针对Yii2的ChartJs小部件
      这需要composer-asset-plugin,它也是yii2的依赖项-因此,如果您安装了yii2,则很可能已经设置好了。 无论运行 composer require 2amigos/yii2-chartjs-widget:~2.0 或添加 " 2amigos/yii2-chartjs-widget " : " ~...
    • shopfacil:ShopFácil-付款方式Bradesco BoletoBancário
      $ composer require gilcierweb/shopfacil or $ composer require gilcierweb/shopfacil:dev-master 对于最新的提交版本: $ composer require gilcierweb/shopfacil @dev 要求 BradescoShopFácil可与PHP 5.3、...
    • enjoyZaragoza:第二DAW项目
      Para este proyecto he utilizado el framework de la empresa Millolab llamado Quaver, el cual esta en vias de desarrollo ...使用 composer 下载最新版本: composer create-project millolab/quaver path/ 将q
    • magento2-autocomplete
      使用手册:Intelipost自动完成模块 介绍 自动完成Intelipost模块负责根据最终客户提供的邮政编码来完成地址数据。 使用进行CEP查询。 安装模块后,将在3页上提供此功能: ... bin/composer requir
    • admix-analytics:Dados做Google Analytics(分析)无信息显示板
      composer require agenciafmd/admix-analytics:dev-master 配置 在 Crie um projeto chamado FMD (客户委托人) 类Ativar API和服务API 瓦伦西亚(Váem Credenciais) »克里达(crear credenciais) »查韦-达...
    • yii2-tinymce-widget:Yii2 的 TinyMCE 所见即所得小部件
      composer require 2amigos/yii2-tinymce-widget:~1.1 或添加 " 2amigos/yii2-tinymce-widget " : " ~1.1 " 到应用程序的composer.json文件的 require 部分。 用法 use dosamigos\tinymce\TinyMce; <?= $form->...
    • pagseguro-modulo-magento-v2:Magento版本2.x的集成模块
      用于Magento 2.x的PagSeguro集成模块 描述 ... 该模块使用PagSeguro以API形式提供的以下功能: 与集成 与集成 要求 社区2.0.8 | 2.1.0至版本2.1.9 ...composer require pagseguro/magento2 此时,系统可能会提示您输入
    • Paghiper-Magento2.3.X-2.4.X:MáduloOficial do PagHiper para Magen
      composer require paghiper/module-magento2 Nesten Momento,马其托共和国邮政总局。 Caso tenha algumadúvida,coma proceder neste dadocumentaçãoofofialial。 执行os comandos: bin/magento setup:upgrade...
    • IntelligenceTrash:Atividade deTópicosAvançados-IFSP汽车
      索布雷·普罗耶托 简历: ... 安装作曲家 Baixar作依赖项目:作曲家更新 ...Caso precision de contato conosco enuma uma mensagem em nosso电子邮件eletronico ou 。 埃塞俄比亚工程技术分析学院和圣保罗州立教育学院-...
    • common
      $ composer require mola/common 睾丸 $ composer test 塞古兰萨 SeleniumVOCE descobrir algum problema relacionadoàsegurança,ENVIE嗯电子邮件对 EM VEZ德城市搜救Ørastreador德problemas。 信贷银行 Licen...