From 4a60029604f1b12d81e135761dc255fe2f500b04 Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Wed, 23 Sep 2015 05:38:56 +0100 Subject: [PATCH] bug fixes --- formats/relations.json | 3 ++- lumen-test/app/Test.php | 21 +++++++++++++++++++++ lumen-test/composer.lock | 8 ++++---- lumen-test/tests/tmp/TestingModel.php | 4 +++- src/Commands/ModelCommand.php | 2 ++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 lumen-test/app/Test.php diff --git a/formats/relations.json b/formats/relations.json index 607911f..7827a12 100644 --- a/formats/relations.json +++ b/formats/relations.json @@ -1,7 +1,8 @@ { "type": "array", - "format": { + "fields": { "type": "object", + "separator": ":", "fields": [ "name", { diff --git a/lumen-test/app/Test.php b/lumen-test/app/Test.php new file mode 100644 index 0000000..37316e3 --- /dev/null +++ b/lumen-test/app/Test.php @@ -0,0 +1,21 @@ +hasMany('App\User'); + } + + public function number() + { + return $this->hasMany('Phone'); + } + +} diff --git a/lumen-test/composer.lock b/lumen-test/composer.lock index 35a97ff..c140d50 100644 --- a/lumen-test/composer.lock +++ b/lumen-test/composer.lock @@ -3699,12 +3699,12 @@ "source": { "type": "git", "url": "https://github.com/webNeat/lumen-generators.git", - "reference": "558ebd5f0a9e2c7e9043d9bff5073873057c5df9" + "reference": "04ce3077cd2723b38424e1ea94844582b67c6b79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webNeat/lumen-generators/zipball/558ebd5f0a9e2c7e9043d9bff5073873057c5df9", - "reference": "558ebd5f0a9e2c7e9043d9bff5073873057c5df9", + "url": "https://api.github.com/repos/webNeat/lumen-generators/zipball/04ce3077cd2723b38424e1ea94844582b67c6b79", + "reference": "04ce3077cd2723b38424e1ea94844582b67c6b79", "shasum": "" }, "require": { @@ -3736,7 +3736,7 @@ "lumen", "rest" ], - "time": "2015-09-23 02:22:02" + "time": "2015-09-23 03:58:39" } ], "aliases": [], diff --git a/lumen-test/tests/tmp/TestingModel.php b/lumen-test/tests/tmp/TestingModel.php index 0181915..ef2d831 100644 --- a/lumen-test/tests/tmp/TestingModel.php +++ b/lumen-test/tests/tmp/TestingModel.php @@ -6,6 +6,8 @@ class TestingModel extends Model { protected $fillable = []; - protected $dates = ["started_at"]; + protected $dates = []; + + } diff --git a/src/Commands/ModelCommand.php b/src/Commands/ModelCommand.php index e11ba04..f919acd 100644 --- a/src/Commands/ModelCommand.php +++ b/src/Commands/ModelCommand.php @@ -73,6 +73,8 @@ class ModelCommand extends BaseCommand { $item['type'] = $type; if(! $item['model']){ $item['model'] = $this->getNamespace() . '\\' . ucwords(str_singular($item['name'])); + } else if(strpos($item['model'], '\\') === false ){ + $item['model'] = $this->getNamespace() . '\\' . $item['model']; } $relations[] = $template->with($item)->get(); }