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.
- 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', ...]
The laravel-enso/core package comes with this library included.