Looking to hire Laravel developers? Try LaraJobs

nullablefields maintained by laravel-enso

Description
Trait for nullable fields
Author
Last update
2017/06/13 09:28 (dev-master)
License
Links
Downloads
117

Comments
comments powered by Disqus

NullableFileds

Codacy Badge StyleCI Total Downloads Latest Stable Version

Trait for nullable fields heavily inspired from michaeldyrynda/laravel-nullable-fields package. Usefull only with Laravel <= 5.3. L5.4 comes with TrimStrings and ConvertEmptyStringsToNull by default.

Use

  1. In the Model where you want empty strings to be set to null add
use LaravelEnso\NullableFileds\app\Traits\NullableFileds

then set the attribute that shold be transformed:

protected $nullableFields = ['attribute', ...]

Note

The laravel-enso/core package comes with this library included.