From cfe5b2f69bb267b6bba635dba8b126c5c00f3b74 Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Wed, 18 Jan 2017 18:21:40 +0000 Subject: [PATCH] updating wn:resources to follow changes on wn:resource --- lumen-test/.env | 2 +- lumen-test/models.yml | 45 +++++++++++++++--------------- lumen-test/storage/database.sqlite | 0 src/Commands/ResourcesCommand.php | 7 +++-- 4 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 lumen-test/storage/database.sqlite diff --git a/lumen-test/.env b/lumen-test/.env index 9e50af8..0b97d69 100644 --- a/lumen-test/.env +++ b/lumen-test/.env @@ -5,7 +5,7 @@ APP_KEY=SomeRandomKey!!! # APP_LOCALE=en # APP_FALLBACK_LOCALE=en -# DB_CONNECTION=mysql +DB_CONNECTION=sqlite # DB_HOST=localhost # DB_PORT=3306 # DB_DATABASE=homestead diff --git a/lumen-test/models.yml b/lumen-test/models.yml index 02bf266..ac7161c 100644 --- a/lumen-test/models.yml +++ b/lumen-test/models.yml @@ -1,22 +1,23 @@ ---- -Post: - belongsToMany: tags - 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 \ No newline at end of file +--- +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/lumen-test/storage/database.sqlite b/lumen-test/storage/database.sqlite new file mode 100644 index 0000000..e69de29 diff --git a/src/Commands/ResourcesCommand.php b/src/Commands/ResourcesCommand.php index 0714e9c..477dc72 100644 --- a/src/Commands/ResourcesCommand.php +++ b/src/Commands/ResourcesCommand.php @@ -26,6 +26,7 @@ class ResourcesCommand extends BaseCommand { $this->call('wn:resource', [ 'name' => $i['name'], 'fields' => $i['fields'], + '--add' => $i['add'], '--has-many' => $i['hasMany'], '--has-one' => $i['hasOne'], '--belongs-to' => $i['belongsTo'], @@ -35,7 +36,7 @@ class ResourcesCommand extends BaseCommand { ]); } - // $this->call('migrate'); + $this->call('migrate'); $this->pivotTables = array_map( 'unserialize', @@ -56,14 +57,14 @@ class ResourcesCommand extends BaseCommand { // ]); } - // $this->call('migrate'); + $this->call('migrate'); } protected function getResourceParams($modelName, $i) { $i['name'] = snake_case($modelName); - foreach(['hasMany', 'hasOne', 'belongsTo', 'belongsToMany'] as $relation){ + foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){ if(isset($i[$relation])){ $i[$relation] = $this->convertArray($i[$relation], ' ', ','); } else {