PHPackages                             temper/laravel-nullable-properties - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. temper/laravel-nullable-properties

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

temper/laravel-nullable-properties
==================================

1.0.1(5y ago)018.3kMITPHPPHP &gt;=7.0

Since Mar 22Pushed 5y ago3 watchersCompare

[ Source](https://github.com/TemperWorks/laravel-nullable-properties)[ Packagist](https://packagist.org/packages/temper/laravel-nullable-properties)[ RSS](/packages/temper-laravel-nullable-properties/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Nullable Properties
===================

[](#nullable-properties)

This package provides automatically nulled properties for Eloquent Models.

When patching an Eloquent Model, it might be common to do something like this:

```
$this->property = $request->get('property');
```

Or even:

```
$this->fill($request->all());
```

A side effect of this is that empty fields in forms are stored in the database as empty strings, even when the database column is nullable.

This can interfere with future queries such as:

```
$users = User::whereNull('favoriteColor')->get();

```

Usage
-----

[](#usage)

Usage is simple. Add:

- The `NullableProperties` trait
- An array named `$nullable`, containing Model property names (similar to arrays like `$fillable` and `$casts`):

```
