From 057199cb8bf193dcb1ca9855f6eb3ccefaf114c9 Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Fri, 20 Jan 2017 18:56:57 +0000 Subject: [PATCH] fixed the duplicate column for the foriegn key bug --- .../app/Http/Controllers/Controller.php | 1 + lumen-test/clean.sh | 43 +++++++++++++++++++ lumen-test/models.yml | 23 ---------- src/Commands/ResourcesCommand.php | 21 +-------- 4 files changed, 45 insertions(+), 43 deletions(-) create mode 100755 lumen-test/clean.sh delete mode 100644 lumen-test/models.yml diff --git a/lumen-test/app/Http/Controllers/Controller.php b/lumen-test/app/Http/Controllers/Controller.php index 0ccb918..9146f93 100644 --- a/lumen-test/app/Http/Controllers/Controller.php +++ b/lumen-test/app/Http/Controllers/Controller.php @@ -8,3 +8,4 @@ class Controller extends BaseController { // } + diff --git a/lumen-test/clean.sh b/lumen-test/clean.sh new file mode 100755 index 0000000..569b693 --- /dev/null +++ b/lumen-test/clean.sh @@ -0,0 +1,43 @@ +# models +rm app/*.php 2> /dev/null + +# migrations +rm database/migrations/*.php 2> /dev/null + +# routes +echo "get(\"/\", function () use (\$app) { + return \$app->welcome(); +});" > app/Http/routes.php + +# Controllers +rm app/Http/Controllers/*.php 2> /dev/null +echo " app/Http/Controllers/Controller.php + +# factories +echo "define(App\User::class, function (\$faker) { + return [ + 'name' => \$faker->name, + 'email' => \$faker->email, + 'password' => str_random(10), + 'remember_token' => str_random(10), + ]; +}); +" > database/factories/ModelFactory.php + +# database +rm database/database.sqlite 2> /dev/null +touch database/database.sqlite diff --git a/lumen-test/models.yml b/lumen-test/models.yml deleted file mode 100644 index ac7161c..0000000 --- a/lumen-test/models.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -Post: - belongsToMany: tags - add: timestamps softDeletes - fields: - title: - schema: string - rules: required - tags: fillable - content: - schema: text nullable - tags: fillable - published_at: - schema: date - rules: date - tags: date fillable -Tag: - belongsToMany: posts - fields: - name: - schema: string unique - rules: required - tags: fillable diff --git a/src/Commands/ResourcesCommand.php b/src/Commands/ResourcesCommand.php index 477dc72..822dde6 100644 --- a/src/Commands/ResourcesCommand.php +++ b/src/Commands/ResourcesCommand.php @@ -36,7 +36,7 @@ class ResourcesCommand extends BaseCommand { ]); } - $this->call('migrate'); + // $this->call('migrate'); // actually needed for pivot seeders ! $this->pivotTables = array_map( 'unserialize', @@ -72,25 +72,6 @@ class ResourcesCommand extends BaseCommand { } } - if($i['belongsTo']){ - $relations = $this->getArgumentParser('relations')->parse($i['belongsTo']); - foreach ($relations as $relation){ - $foreignName = ''; - - if(! $relation['model']){ - $foreignName = snake_case($relation['name']) . '_id'; - } else { - $names = array_reverse(explode("\\", $relation['model'])); - $foreignName = snake_case($names[0]) . '_id'; - } - - $i['fields'][$foreignName] = [ - 'schema' => 'integer', - 'tags' => 'key' - ]; - } - } - if($i['belongsToMany']){ $relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']); foreach ($relations as $relation){