haegemon / lara-array
Lara-array provide postgresql array datatype support at Eloquent ORM.
dev-master
2018-02-12 07:32 UTC
Requires
- php: >=5.4.0
- illuminate/support: >=5.0.0
This package is not auto-updated.
Last update: 2024-11-22 14:29:43 UTC
README
Lara-array provide postgresql array datatype support at Eloquent ORM. Inspired by darrylkuhn/dialect.
Installation
Require this package in your composer.json
file:
"haegemon/lara-array": "dev-master"
...then run composer update
to download the package to your vendor directory.
Usage
The feature is exposed through a trait rewrite standart casting attributes to change array parse from json_decode to special parser for postgresql array. For example we could create a Photos model like this:
use Eloquent\LaraArray\LaraArray as LaraArray; class Photo extends Eloquent { use LaraArray; protected $casts = [ 'marks' => 'array', ]; }
And then this:
$marks = $photo->marks; var_dump($marks); // array(2) { [0]=> string(1) "5" [1]=> string(1) "2" }