diff --git a/README.md b/README.md index 8ce9f58..3732528 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ A collection of generators for [Lumen](http://lumen.laravel.com) and [Laravel 5] - [Migration Generator](#migration-generator) - - [Pivot Table Generator](#pivot-table-generator)(New on version 1.1.0) + - [Pivot Table Generator](#pivot-table-generator) (Since version 1.1.0) - [Controller Generator](#controller-generator) @@ -31,6 +31,8 @@ A collection of generators for [Lumen](http://lumen.laravel.com) and [Laravel 5] - [Testing](#testing) +- [Development Notes](#development_notes) + - [Contributing](#contributing) ## Why ? @@ -365,7 +367,7 @@ wn:migration table [--schema=...] [--keys=...] [--file=...] - **table**: the name of the table to create. -- **--file**: The migration file name. By default the name follows the patern `date_time_create_table_name.php`. +- **--file**: The migration file name (to speicify only for testing purpose). By default the name follows the patern `date_time_create_tableName_table.php`. - **--schema**: the schema of the table using the syntax `field1:type.arg1,ag2:modifier1:modifier2.. field2:...`. The `type` could be `text`, `string.50`, `decimal.5,2` for example. Modifiers can be `unique` or `nullable` for example. [See documentation](http://laravel.com/docs/5.1/migrations#creating-columns) for the list of available types and modifiers. @@ -602,6 +604,34 @@ Product: To test the generators, I included a fresh lumen installation under the folder `lumen-test` to which I added this package and have written some acceptance tests using [Codeception](http://codeception.com/). To run tests you just have to execute the `install.sh` to install dependencies then execute `test.sh`. +## Development Notes + +- **Version 1.0.0** + + - Model Generator + + - Migration Generator + + - Controller Generator + + - Routes Generator + + - Resource Generator + + - Multiple Resources From File + +- **Version 1.1.0** + + - Pivot table generator added. + + - belongsToMany relationship added to model generator. + + - Multiple resources generator adds foreign keys for belongsTo relationships automatically. + + - Multiple resources generator adds pivot tables for belongsToMany relationships automatically. + + - Generated migrations file names changed to be supported by `migrate` command. + ## Contributing Pull requests are welcome :D diff --git a/lumen-test/app/Http/Controllers/ProjectsController.php b/lumen-test/app/Http/Controllers/ProjectsController.php deleted file mode 100644 index 3e8e933..0000000 --- a/lumen-test/app/Http/Controllers/ProjectsController.php +++ /dev/null @@ -1,10 +0,0 @@ - "required", - ]; - - public function tags() - { - return $this->belongsToMany("App\Tag")->withTimestamps(); - } - - -} diff --git a/lumen-test/app/Tag.php b/lumen-test/app/Tag.php deleted file mode 100644 index 3118793..0000000 --- a/lumen-test/app/Tag.php +++ /dev/null @@ -1,21 +0,0 @@ - "required|unique", - ]; - - public function projects() - { - return $this->belongsToMany("App\Project")->withTimestamps(); - } - - -} diff --git a/lumen-test/app/Tags.php b/lumen-test/app/Tags.php deleted file mode 100644 index 4b79279..0000000 --- a/lumen-test/app/Tags.php +++ /dev/null @@ -1,21 +0,0 @@ - "required|unique", - ]; - - public function projects() - { - return $this->belongsToMany("App\Project")->withTimestamps(); - } - - -} diff --git a/lumen-test/bootstrap/app.php b/lumen-test/bootstrap/app.php index 1b0d1e1..52b393f 100644 --- a/lumen-test/bootstrap/app.php +++ b/lumen-test/bootstrap/app.php @@ -2,7 +2,7 @@ require_once __DIR__.'/../vendor/autoload.php'; -// Dotenv::load(__DIR__.'/../'); +Dotenv::load(__DIR__.'/../'); /* |-------------------------------------------------------------------------- diff --git a/lumen-test/database/migrations/2015_10_04_061849_create_project_tag.php b/lumen-test/database/migrations/2015_10_04_061849_create_project_tag.php deleted file mode 100644 index b1ea8ce..0000000 --- a/lumen-test/database/migrations/2015_10_04_061849_create_project_tag.php +++ /dev/null @@ -1,29 +0,0 @@ -increments('id'); - $table->integer('project_id')->unsigned()->index(); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('project_id') - ->references('id') - ->on('projects'); - $table->foreign('tag_id') - ->references('id') - ->on('tags'); - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('project_tag'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_065133_create_project_tag.php b/lumen-test/database/migrations/2015_10_04_065133_create_project_tag.php deleted file mode 100644 index b1ea8ce..0000000 --- a/lumen-test/database/migrations/2015_10_04_065133_create_project_tag.php +++ /dev/null @@ -1,29 +0,0 @@ -increments('id'); - $table->integer('project_id')->unsigned()->index(); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('project_id') - ->references('id') - ->on('projects'); - $table->foreign('tag_id') - ->references('id') - ->on('tags'); - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('project_tag'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_065133_create_projects.php b/lumen-test/database/migrations/2015_10_04_065133_create_projects.php deleted file mode 100644 index d12241d..0000000 --- a/lumen-test/database/migrations/2015_10_04_065133_create_projects.php +++ /dev/null @@ -1,24 +0,0 @@ -increments('id'); - $table->string('name'); - $table->text('descr')->nullable(); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('projects'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_065133_create_tags.php b/lumen-test/database/migrations/2015_10_04_065133_create_tags.php deleted file mode 100644 index 7b35cd1..0000000 --- a/lumen-test/database/migrations/2015_10_04_065133_create_tags.php +++ /dev/null @@ -1,23 +0,0 @@ -increments('id'); - $table->string('name'); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('tags'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_065820_create_projects.php b/lumen-test/database/migrations/2015_10_04_065820_create_projects.php deleted file mode 100644 index d12241d..0000000 --- a/lumen-test/database/migrations/2015_10_04_065820_create_projects.php +++ /dev/null @@ -1,24 +0,0 @@ -increments('id'); - $table->string('name'); - $table->text('descr')->nullable(); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('projects'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_065820_create_tags.php b/lumen-test/database/migrations/2015_10_04_065820_create_tags.php deleted file mode 100644 index 7b35cd1..0000000 --- a/lumen-test/database/migrations/2015_10_04_065820_create_tags.php +++ /dev/null @@ -1,23 +0,0 @@ -increments('id'); - $table->string('name'); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('tags'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070216_create_project_tag.php b/lumen-test/database/migrations/2015_10_04_070216_create_project_tag.php deleted file mode 100644 index b1ea8ce..0000000 --- a/lumen-test/database/migrations/2015_10_04_070216_create_project_tag.php +++ /dev/null @@ -1,29 +0,0 @@ -increments('id'); - $table->integer('project_id')->unsigned()->index(); - $table->integer('tag_id')->unsigned()->index(); - $table->foreign('project_id') - ->references('id') - ->on('projects'); - $table->foreign('tag_id') - ->references('id') - ->on('tags'); - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('project_tag'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070216_create_projects.php b/lumen-test/database/migrations/2015_10_04_070216_create_projects.php deleted file mode 100644 index d12241d..0000000 --- a/lumen-test/database/migrations/2015_10_04_070216_create_projects.php +++ /dev/null @@ -1,24 +0,0 @@ -increments('id'); - $table->string('name'); - $table->text('descr')->nullable(); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('projects'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070216_create_tags.php b/lumen-test/database/migrations/2015_10_04_070216_create_tags.php deleted file mode 100644 index 7b35cd1..0000000 --- a/lumen-test/database/migrations/2015_10_04_070216_create_tags.php +++ /dev/null @@ -1,23 +0,0 @@ -increments('id'); - $table->string('name'); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('tags'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070253_create_projects.php b/lumen-test/database/migrations/2015_10_04_070253_create_projects.php deleted file mode 100644 index d12241d..0000000 --- a/lumen-test/database/migrations/2015_10_04_070253_create_projects.php +++ /dev/null @@ -1,24 +0,0 @@ -increments('id'); - $table->string('name'); - $table->text('descr')->nullable(); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('projects'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070253_create_tags.php b/lumen-test/database/migrations/2015_10_04_070253_create_tags.php deleted file mode 100644 index 7b35cd1..0000000 --- a/lumen-test/database/migrations/2015_10_04_070253_create_tags.php +++ /dev/null @@ -1,23 +0,0 @@ -increments('id'); - $table->string('name'); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('tags'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070410_create_projects.php b/lumen-test/database/migrations/2015_10_04_070410_create_projects.php deleted file mode 100644 index d12241d..0000000 --- a/lumen-test/database/migrations/2015_10_04_070410_create_projects.php +++ /dev/null @@ -1,24 +0,0 @@ -increments('id'); - $table->string('name'); - $table->text('descr')->nullable(); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('projects'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070410_create_tags.php b/lumen-test/database/migrations/2015_10_04_070410_create_tags.php deleted file mode 100644 index 7b35cd1..0000000 --- a/lumen-test/database/migrations/2015_10_04_070410_create_tags.php +++ /dev/null @@ -1,23 +0,0 @@ -increments('id'); - $table->string('name'); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('tags'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070428_create_projects.php b/lumen-test/database/migrations/2015_10_04_070428_create_projects.php deleted file mode 100644 index d12241d..0000000 --- a/lumen-test/database/migrations/2015_10_04_070428_create_projects.php +++ /dev/null @@ -1,24 +0,0 @@ -increments('id'); - $table->string('name'); - $table->text('descr')->nullable(); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('projects'); - } -} diff --git a/lumen-test/database/migrations/2015_10_04_070428_create_tags.php b/lumen-test/database/migrations/2015_10_04_070428_create_tags.php deleted file mode 100644 index 7b35cd1..0000000 --- a/lumen-test/database/migrations/2015_10_04_070428_create_tags.php +++ /dev/null @@ -1,23 +0,0 @@ -increments('id'); - $table->string('name'); - // Constraints declaration - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('tags'); - } -} diff --git a/src/Commands/MigrationCommand.php b/src/Commands/MigrationCommand.php index b88bd1b..9239334 100644 --- a/src/Commands/MigrationCommand.php +++ b/src/Commands/MigrationCommand.php @@ -7,7 +7,7 @@ class MigrationCommand extends BaseCommand { {table : The table name.} {--schema= : the schema.} {--keys= : foreign keys.} - {--file= : name of the migration file.} + {--file= : name of the migration file (to use only for testing purpose).} {--parsed : tells the command that arguments have been already parsed. To use when calling the command from an other command and passing the parsed arguments and options} '; // {action : One of create, add, remove or drop options.} @@ -31,7 +31,7 @@ class MigrationCommand extends BaseCommand { $file = $this->option('file'); if(! $file){ - $file = date('Y_m_d_His_') . snake_case($name); + $file = date('Y_m_d_His_') . snake_case($name) . '_table'; } $this->save($content, "./database/migrations/{$file}.php"); diff --git a/src/Commands/PivotTableCommand.php b/src/Commands/PivotTableCommand.php index c40c713..8e4b7be 100644 --- a/src/Commands/PivotTableCommand.php +++ b/src/Commands/PivotTableCommand.php @@ -6,7 +6,7 @@ class PivotTableCommand extends BaseCommand { protected $signature = 'wn:pivot-table {model1 : Name of the first model or table} {model2 : Name of the second model or table} - {--file= : name of the migration file.} + {--file= : name of the migration file (to use only for testing purpose).} '; protected $description = 'Generates creation migration for a pivot table'; diff --git a/templates/migration.wnt b/templates/migration.wnt index ef942af..7b99afe 100644 --- a/templates/migration.wnt +++ b/templates/migration.wnt @@ -3,7 +3,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class {{name}}Migration extends Migration +class {{name}}Table extends Migration { public function up()