PHPackages                             vinicius73/laravel-model-shield - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. vinicius73/laravel-model-shield

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

vinicius73/laravel-model-shield
===============================

Validation package for models Laravel 5+

v1.1(11y ago)12402MITPHPPHP &gt;=5.4.0

Since Sep 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/vinicius73/laravel-model-shield)[ Packagist](https://packagist.org/packages/vinicius73/laravel-model-shield)[ RSS](/packages/vinicius73-laravel-model-shield/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (4)Versions (6)Used By (0)

Laravel Model Shield
====================

[](#laravel-model-shield)

[![Latest Stable Version](https://camo.githubusercontent.com/c006f442a6728a204be7a5c812af4d86c1f54fa87208ce1aad2ce828fdddfd74/68747470733a2f2f706f7365722e707567782e6f72672f76696e696369757337332f6c61726176656c2d6d6f64656c2d736869656c642f762f737461626c652e737667)](https://packagist.org/packages/vinicius73/laravel-model-shield) [![Total Downloads](https://camo.githubusercontent.com/d55245d1ade18d4fb68bfb50983e9ba987ec6dccb05a8c94523c56ec4bd137eb/68747470733a2f2f706f7365722e707567782e6f72672f76696e696369757337332f6c61726176656c2d6d6f64656c2d736869656c642f646f776e6c6f6164732e737667)](https://packagist.org/packages/vinicius73/laravel-model-shield) [![Latest Unstable Version](https://camo.githubusercontent.com/6c0f7e2e22da25f1fdbca967b871c8ed3a88fdb3c5a705df6697452df3b8dd4b/68747470733a2f2f706f7365722e707567782e6f72672f76696e696369757337332f6c61726176656c2d6d6f64656c2d736869656c642f762f756e737461626c652e737667)](https://packagist.org/packages/vinicius73/laravel-model-shield) [![License](https://camo.githubusercontent.com/edc75f0083b2bafaa88e126782c47ed50fbecd431f45e0d00099de12fb881d39/68747470733a2f2f706f7365722e707567782e6f72672f76696e696369757337332f6c61726176656c2d6d6f64656c2d736869656c642f6c6963656e73652e737667)](https://packagist.org/packages/vinicius73/laravel-model-shield)

installation
------------

[](#installation)

Add the new required package in your composer.json

```
"vinicius73/laravel-model-shield": "~1.1"

```

Run `composer update` or `php composer.phar update`.

After composer command, add new service provider in `app/config/app.php` :

```
'Vinicius73\ModelShield\ModelShieldServiceProvider',
```

Now, add new aliases in `app/config/app.php`.

```
'Shield' => 'Vinicius73\ModelShield\Facades\Shield',
```

Finally publish the configuration file of the package `php artisan config:publish vinicius73/laravel-model-shield`

Usage
-----

[](#usage)

You have two ways to use, extending the class `Vinicius73\ModelShield\ModelShield`, or using the trait `Vinicius73\ModelShield\Traits\Shield`

```
use Vinicius73\ModelShield\ModelShield;

class Student extends ModelShield
{
   protected $table = 'students';
}
```

or

```
use Vinicius73\ModelShield\Traits\Shield;

class Student extends Eloquent
{
   use Shield;

   protected $table = 'students';
}
```

Usage in Sentry
---------------

[](#usage-in-sentry)

Use:

```
use Cartalyst\Sentry\Users\Eloquent\User as SentryModel;
use Vinicius73\ModelShield\Traits\ShieldSentry;

class User extends SentryModel
{
   use ShieldSentry;
}
```

### Validation Rules

[](#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`.

```
