From e5b48176c4f4832104653d875efc31d6ecab14ff Mon Sep 17 00:00:00 2001 From: Jake Mitchell Date: Sun, 26 Jun 2016 01:12:17 +0000 Subject: [PATCH] Allow users to pass unserialized array --- src/Meta.php | 2 +- tests/MetaTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Meta.php b/src/Meta.php index 90756aa..3c2ec08 100644 --- a/src/Meta.php +++ b/src/Meta.php @@ -26,7 +26,7 @@ class Meta extends Model implements FoundationModel, MetaContract * @return callable */ public static function create( array $args = [] ){ - $args['meta'] = (isset($args['meta'])) ? $args['meta'] : serialize([]); + $args['meta'] = (isset($args['meta'])) ? ((gettype($args['meta']) === 'array') ? serialize($args['meta']) : $args['meta']) : serialize([]); $args['uuid'] = (isset($args['uuid'])) ? $args['uuid'] : Uuid::uuid4(); return parent::create($args); diff --git a/tests/MetaTest.php b/tests/MetaTest.php index 5e26633..22d2c03 100644 --- a/tests/MetaTest.php +++ b/tests/MetaTest.php @@ -34,7 +34,7 @@ class MetaTest extends \PHPUnit_Framework_TestCase public function testUuidQuery () { $model = Meta::create([ - 'meta' => serialize(['name' => 'Tony']) + 'meta' => ['name' => 'Tony'] ]); $queried = Meta::withUuid($model->getUuid())->first();