Download the PHP package little-apps/serializable-model without Composer
On this page you can find all versions of the php package little-apps/serializable-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download little-apps/serializable-model
More information about little-apps/serializable-model
Files in little-apps/serializable-model
Package serializable-model
Short Description Simple package for serializable columns in a Laravel model.
License MIT
Informations about the package serializable-model
SerializableModel
SerializableModel is simple package for serializable columns in a Laravel model. It utilizes the serialize
and unserialize
PHP functions to store values in the database.
License
SerializableModel is free and open source, and is licensed under the MIT License.
Copyright 2018 Little Apps
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Installation
Install using composer:
Usage
This package includes a trait which can be included in any class that inherits Illuminate\Database\Eloquent\Model
.
The next step is to define the columns that should be serialized in the $serializable
property.
Any value that is assigned to the addresses
or phone_numbers
columns will stored in the database as a string representation of the original data type.
The value of columns are unserialized (if nesessary) and returned. The following follows the values set in the example above.
Database Migrations
The data type to use for a serializable column in a MySQL database can vary. The PHP documentation for serializable
and this answer on StackOverflow recommends it be a BLOB
, and not CHAR
or TEXT
. The command for a BLOB
in a Laravel database migration is binary()
.
Notes
- To save space in the database, strings are left as is and not serialized.
- Resources can't be serialized and trying to do so will result in undefined behavior.
Show Your Support
Little Apps relies on people like you to keep our software running. If you would like to show your support for Little System Cleaner, then you can make a donation using PayPal, Payza or credit card (via Stripe). Please note that any amount helps (even just $1).