Allow users to pass unserialized array

This commit is contained in:
Jake Mitchell 2016-06-26 01:12:17 +00:00
parent 70cd832876
commit e5b48176c4
2 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ class Meta extends Model implements FoundationModel, MetaContract
* @return callable * @return callable
*/ */
public static function create( array $args = [] ){ 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(); $args['uuid'] = (isset($args['uuid'])) ? $args['uuid'] : Uuid::uuid4();
return parent::create($args); return parent::create($args);

View File

@ -34,7 +34,7 @@ class MetaTest extends \PHPUnit_Framework_TestCase
public function testUuidQuery () public function testUuidQuery ()
{ {
$model = Meta::create([ $model = Meta::create([
'meta' => serialize(['name' => 'Tony']) 'meta' => ['name' => 'Tony']
]); ]);
$queried = Meta::withUuid($model->getUuid())->first(); $queried = Meta::withUuid($model->getUuid())->first();