Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed #35

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/vendor/
/about/
*.sublime-*

.idea
tests/_output/*

lumen-test/app
Expand Down
26 changes: 25 additions & 1 deletion src/Commands/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,31 @@ class MigrationCommand extends BaseCommand {
// {action : One of create, add, remove or drop options.}
// The action is only create for the moment

protected $description = 'Generates a migration to create a table with schema';
protected $description = 'Generates a migration file.

<comment>Examples:</comment>
- wn:migration categories --schema="name:string.255 active:tinyint.1:default.0 slug:string" --add="timestamps,softDeletes"
- wn:migration galleries --schema="name:string user_id:unsignedInteger" --add="timestamps,softDeletes" --keys="user_id"

<comment>Available fields:</comment>
string(string $column, int $length = 255)
text(string $column) | mediumText longText
boolean(string $column)
integer(string $column, bool $autoIncrement = false, bool $unsigned = false) | tinyInteger smallInteger mediumInteger bigInteger
unsignedInteger(string $column, bool $autoIncrement = false) | unsignedTinyInteger unsignedSmallInteger unsignedMediumInteger unsignedBigInteger
float(string $column, int $total = 8, int $places = 2)
decimal(string $column, int $total = 8, int $places = 2)
double(string $column, int|null $total = null, int|null $places = null)
enum(string $column, array $allowed)
json(string $column)
jsonb(string $column)
date(string $column)
dateTime(string $column)
binary(string $column)
uuid(string $column)
ipAddress(string $column)
macAddress(string $column)
';

public function handle()
{
Expand Down
7 changes: 4 additions & 3 deletions src/Commands/SeederCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
class SeederCommand extends BaseCommand {

protected $signature = 'wn:seeder
{model : full qualified name of the model.}
{--count=10 : number of elements to add in database.}
{model : full qualified name of the model}
{--count=10 : number of elements to add in database}
{--force= : override the existing files}
{--ns=App\Models : model namespace }
';

protected $description = 'Generates a seeder';

public function handle()
{
$model = $this->argument('model');
$model = $this->option('ns').'\\'.$this->argument('model');
$name = $this->getSeederName($model);
$file = "./database/seeds/{$name}.php";

Expand Down
2 changes: 1 addition & 1 deletion src/CommandsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function register()
$this->registerResourcesCommand();
$this->registerPivotTableCommand();
$this->registerFactoryCommand();
// registerSeederCommand
$this->registerSeederCommand();
// registerPivotSeederCommand
// registerTestCommand
}
Expand Down
2 changes: 1 addition & 1 deletion templates/factory.wnt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Factory definition for model {{model}}.
*/
$factory->define({{model}}::class, function ($faker) {
$factory->define({{model}}::class, function (Faker\Generator $faker) {
return [
{{factory_fields}}
];
Expand Down
3 changes: 3 additions & 0 deletions templates/migration.wnt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class {{name}}Table extends Migration

public function up()
{
if (Schema::hasTable('{{table}}')) {
Schema::drop('{{table}}');
}
Schema::create('{{table}}', function(Blueprint $table) {
$table->increments('id');
{{schema}}
Expand Down
10 changes: 5 additions & 5 deletions templates/routes.wnt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Routes for resource {{resource}}
*/
$app->get('{{resource}}', '{{controller}}@all');
$app->get('{{resource}}/{id}', '{{controller}}@get');
$app->post('{{resource}}', '{{controller}}@add');
$app->put('{{resource}}/{id}', '{{controller}}@put');
$app->delete('{{resource}}/{id}', '{{controller}}@remove');
Route::get('{{resource}}', '{{controller}}@all');
Route::get('{{resource}}/{id}', '{{controller}}@get');
Route::post('{{resource}}', '{{controller}}@add');
Route::put('{{resource}}/{id}', '{{controller}}@put');
Route::delete('{{resource}}/{id}', '{{controller}}@remove');