diff --git a/README.md b/README.md index db473fe..95d259d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Add the generators package to your composer.json by running the command: Then add the service provider in the file `app/Providers/AppServiceProvider.php`like the following: -``` +```php public function register() { if ($this->app->environment() == 'local') { @@ -33,27 +33,28 @@ public function register() If you run the command `php artisan list` you will see the list of added commands: ``` -wn - wn:controller Generates RESTful controller using the RESTActions trait - wn:controller:rest-actions Generates REST actions trait to use into controllers - wn:migration Generates a migration to create a table with schema - wn:model Generates a model class for a RESTfull resource - wn:resource Generates a model, migration, controller and routes for RESTful resource - wn:resources Generates multiple resources from a file - wn:route Generates RESTful routes. +wn:controller Generates RESTful controller using the RESTActions trait +wn:controller:rest-actions Generates REST actions trait to use into controllers +wn:migration Generates a migration to create a table with schema +wn:model Generates a model class for a RESTfull resource +wn:resource Generates a model, migration, controller and routes for RESTful resource +wn:resources Generates multiple resources from a file +wn:route Generates RESTful routes. ``` ## Quick Usage To generate a RESTful resource for your application (model, migration, controller and RESTful routes), you simply need to run one single command. For example: -`php artisan wn:resource task "name;string;required;fillable project_id;integer:unsigned;numeric;fillable,key due;date;;date" --belongs-to=project` +``` +php artisan wn:resource task "name;string;required;fillable project_id;integer:unsigned;numeric;fillable,key due;date;;date" --belongs-to=project +``` will generate these files: **app/Task.php** -``` +```php delete('task/{id}', 'TasksController@remove'); **database/migrations/date_time_create_tasks.php** -``` +```php "required", @@ -315,7 +324,9 @@ class Task extends Model { The `wn:migration` command is used to generate a migration to create a table with schema. It has the following syntax: -`wn:migration table [--schema=...] [--keys=...] [--file=...]` +``` +wn:migration table [--schema=...] [--keys=...] [--file=...] +``` - **table**: the name of the table to create. @@ -323,9 +334,12 @@ The `wn:migration` command is used to generate a migration to create a table wit - **--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. -`php artisan wn:migration tasks --schema="amount:decimal.5,2:after.'size':default.8 title:string:nullable"` gives: - ``` +php artisan wn:migration tasks --schema="amount:decimal.5,2:after.'size':default.8 title:string:nullable" +``` +gives: + +```php foreign('category_type_id') ->references('id') @@ -393,7 +410,7 @@ The second command is `wn:controller` which actually generates the controller. T `php artisan wn:controller Task --no-routes` gives: -``` +```php get('project-type', 'ProjectTypesController@all'); $app->get('project-type/{id}', 'ProjectTypesController@get'); $app->post('project-type', 'ProjectTypesController@add'); @@ -458,7 +475,7 @@ The `wn:resources` (note the "s" in "resources") command takes the generation pr The file given to the command should be a valid YAML file ( for the moment, support of other types like XML or JSON could be added in the future). An example is the following: -``` +```yaml --- Store: hasMany: products @@ -493,4 +510,4 @@ Product: ## Contributing -Pull requests are welcome :D \ No newline at end of file +Pull requests are welcome :D