{"repo":"michaeldyrynda/laravel-nullable-fields","free":true,"listed":false,"github":"https://github.com/michaeldyrynda/laravel-nullable-fields","clone":"git clone https://github.com/michaeldyrynda/laravel-nullable-fields.git","description":"Handles saving empty fields as null for Eloquent models","language":"PHP","stars":103,"topics":["laravel","eloquent","eloquent-models","package"],"license":"MIT","category":"databases-storage","readme_excerpt":"Nullable database fields for the Laravel PHP Framework Often times, database fields that are not assigned values are defaulted to null . This is particularly important when creating records with foreign key constraints, where the relationship is not yet established. More recent versions of MySQL will convert the value to an empty string if the field is not configured to allow null. Be aware that older versions may actually return an error. Laravel does not currently support automatically setting nullable database fields as null when the value assigned to a given attribute is empty. Installation This trait is installed via Composer. To install, simply add it to your composer.json file: In order to use this trait, import it in your Eloquent model, then set the protected $nullable property as an array of fields you would like to be saved as null when empty. Now, any time you are saving a UserProfile profile instance, any empty attributes that are set in the $nullable property will be saved as null . If you want to extend this behaviour to all fields on your model, you may do so by specifying $nullable as : More information Working with nullable fields in Eloquent models - first iteration Working with nullable fields in Eloquent models - Part Deux - second iteration, covers the details of this package Support If you are having general issues with this package, feel free to contact me on Twitter. If you believe you have found an issue, please report it using the GitHub issue track","default_branch":null,"files":null,"tree":[],"storefront":"/r/michaeldyrynda","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/michaeldyrynda/laravel-nullable-fields/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}