Download the PHP package vinicius73/laravel-model-shield without Composer
On this page you can find all versions of the php package vinicius73/laravel-model-shield. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vinicius73/laravel-model-shield
More information about vinicius73/laravel-model-shield
Files in vinicius73/laravel-model-shield
Package laravel-model-shield
Short Description Validation package for models Laravel 4.*
License MIT
Informations about the package laravel-model-shield
Laravel Model Shield
installation
Add the new required package in your composer.json
Run composer update
or php composer.phar update
.
After composer command, add new service provider in app/config/app.php
:
Now, add new aliases in app/config/app.php
.
Finally publish the configuration file of the package php artisan config:publish vinicius73/laravel-model-shield
Usage
You have two ways to use, extending the class Vinicius73\ModelShield\ModelShield
, or using the trait Vinicius73\ModelShield\Traits\Shield
or
Usage in Sentry
Use:
Validation Rules
Your validation rules are organized into separate files, to better organization.
By default the files are in app/models/rules/
, but you can change it by changing the local variable path
of the configuration file
app/config/packages/vinicius73/laravel-model-shield/config.php
.
Each rules file can contain up to three sets of rules: default
, creating
and updating
.
The differential Laravel Model Shield is the possibility of having a specific set of rules for each situation.
- default is the set of rules that will always be used in all validations.
- creating is the set of rules that will be used when you are creating a new record with his model.
- updating is the set of rules that will be used when you are updating a record in your model.
creating
andupdating
inherit the rules ofdefault
and replace if necessary, creating a wide range of possibilities.
Custom Messages and Attribute Names
You can also define custom error messages and more beautiful names to their attributes.
Just set the values for custom_messages
and attribute_names
, Shield will do the rest.
Validating
Shield validates the model every time you save it, either through the $model->save()
or $model->update()
;
It will return true
, indicating that the modem is valid and was successfully saved.
And false
stating that the model is not valid and was not saved.
Errors
When the model is not saved you can redeem the error messages by the method $model->getErrors()
, which returns an object Illuminate\Support\MessageBag
Credits
All versions of laravel-model-shield with dependencies
illuminate/database Version 4.*
illuminate/validation Version 4.*
illuminate/support Version 4.*