Compare commits

..

25 Commits

Author SHA1 Message Date
Arthur
f1debe575e
Package name update
Package name update
2020-04-06 20:12:04 +03:00
Arthur
2efa3595a5
Update README.md 2020-04-06 20:10:23 +03:00
Arthur
c46846d978
Update dependencies
Update dependencies to work with Lumen v.6
2020-04-06 20:06:58 +03:00
Amine Ben hammou
8d804e09eb
Merge pull request #50 from davidporos92/hotfix/migration-generator
Delete old migration file if exists when creating a new one
2018-06-09 05:30:26 +00:00
Amine Ben hammou
a6008f4a40 Merge pull request #48 from AfzalH/master
Some fixes for latest lumen. Also added customized response for NOT_FOUND and NO_CONTENT response
2017-10-23 00:12:29 +02:00
Pörös Dávid
86493ab228 delete old migration file
refs #44
2017-10-21 01:19:28 +02:00
Afzal Hossain
50c3e78483 Better control over not_found and no_content response 2017-10-20 19:04:20 +06:00
Afzal Hossain
ee03649641 Single quote around model to avoid IDE warning 2017-10-20 19:02:37 +06:00
Afzal Hossain
8ee7bbe6b7 $app->get() no longer works. Replaced. 2017-10-20 19:01:22 +06:00
Amine Ben hammou
73e470ec15 Merge pull request #40 from josiahdahl/laravel-routes
Enable Creating Laravel Style Routes
2017-08-09 00:57:18 +02:00
Josiah Dahl
c5218a1fd8 Merge branch 'master' into laravel-routes 2017-08-08 14:10:20 -07:00
Amine Ben hammou
014c617cc5 Merge pull request #39 from josiahdahl/sequential-model-filenames
Sequential Filenames with Resources Command
2017-08-08 21:52:03 +02:00
Josiah Dahl
8b6e2db315 Added database for testing 2017-08-07 12:28:22 -07:00
Josiah Dahl
a2cb5e4437 Add database creation for testing 2017-08-07 12:23:08 -07:00
Josiah Dahl
9a82b80cb1 fix test bug 2017-08-07 12:12:39 -07:00
Josiah Dahl
56f0d9c0a9 Ensure commands work and tests pass 2017-08-07 11:51:53 -07:00
Josiah Dahl
573d55c9b2 updated README 2017-08-07 11:51:43 -07:00
Josiah Dahl
a951151697 Finalize testing 2017-08-07 11:02:36 -07:00
Josiah Dahl
5e2c21855e Tests are failing only for the new route options 2017-08-06 23:06:04 -07:00
Josiah Dahl
2817f3591b Add resources data 2017-08-06 23:01:36 -07:00
Josiah Dahl
a2cf22d426 Added Laravel Routes
- New template
- Command updates
2017-08-06 20:54:39 -07:00
Josiah Dahl
6e00a91eea Fixed string padding 2017-08-06 15:56:01 -07:00
Josiah Dahl
afa5bf1f0c Pad the model index to 3 characters 2017-08-06 09:44:50 -07:00
Josiah Dahl
982dee15fc Possible codeception updates 2017-08-06 09:37:25 -07:00
Josiah Dahl
434e7f6b2c Testing Resources Command
Finialized testing the changes to the resources command.
2017-08-06 09:36:57 -07:00
23 changed files with 696 additions and 84 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ tests/_output/*
lumen-test/app lumen-test/app
lumen-test/database lumen-test/database
lumen-test/tests/tmp lumen-test/tests/tmp
.idea

View File

@ -5,7 +5,7 @@
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/838624c3-208d-4ba5-84aa-3afc76b093bb/mini.png)](https://insight.sensiolabs.com/projects/838624c3-208d-4ba5-84aa-3afc76b093bb) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/838624c3-208d-4ba5-84aa-3afc76b093bb/mini.png)](https://insight.sensiolabs.com/projects/838624c3-208d-4ba5-84aa-3afc76b093bb)
[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://github.com/webNeat/lumen-generators/blob/master/LICENSE) [![License](https://poser.pugx.org/laravel/framework/license.svg)](https://github.com/webNeat/lumen-generators/blob/master/LICENSE)
A collection of generators for [Lumen](http://lumen.laravel.com) and [Laravel 5](http://laravel.com/). A collection of generators for [Lumen](http://lumen.laravel.com) and [Laravel 6](http://laravel.com/).
## Contents ## Contents
@ -509,7 +509,9 @@ The second command is `wn:controller` which actually generates the controller. T
- **--no-routes**: Since routes are generated by default for the controller, this option is used to tell the generator "do not generate routes !". - **--no-routes**: Since routes are generated by default for the controller, this option is used to tell the generator "do not generate routes !".
- **--force**: tells the generator to override the existing file. - **--force**: tells the generator to override the existing file.
- **--laravel**: create Laravel style routes
`php artisan wn:controller Task --no-routes` gives: `php artisan wn:controller Task --no-routes` gives:
@ -539,6 +541,9 @@ The `wn:route` command is used to generate RESTfull routes for a controller. It
- **--force**: tells the generator to override the existing file. - **--force**: tells the generator to override the existing file.
- **--laravel**: create Laravel style routes
`php artisan wn:route project-type` adds the following routes: `php artisan wn:route project-type` adds the following routes:
```php ```php
@ -549,6 +554,17 @@ $app->put('project-type/{id}', 'ProjectTypesController@put');
$app->delete('project-type/{id}', 'ProjectTypesController@remove'); $app->delete('project-type/{id}', 'ProjectTypesController@remove');
``` ```
`php artisan wn:route project-type --laravel` adds the following routes:
```php
Route::get('project-type', 'ProjectTypesController@all');
Route::get('project-type/{id}', 'ProjectTypesController@get');
Route::post('project-type', 'ProjectTypesController@add');
Route::put('project-type/{id}', 'ProjectTypesController@put');
Route::delete('project-type/{id}', 'ProjectTypesController@remove');
```
### Resource Generator ### Resource Generator
The `wn:resource` command makes it very easy to generate a RESTful resource. It generates a model, migration, controller and routes. The syntax is : `wn:resource name fields [--add=...] [--has-many=...] [--has-one=...] [--belongs-to=...] [--migration-file=...] [--path=...] [--force=true]` The `wn:resource` command makes it very easy to generate a RESTful resource. It generates a model, migration, controller and routes. The syntax is : `wn:resource name fields [--add=...] [--has-many=...] [--has-one=...] [--belongs-to=...] [--migration-file=...] [--path=...] [--force=true]`
@ -581,6 +597,9 @@ The `wn:resource` command makes it very easy to generate a RESTful resource. It
- **--force**: tells the generator to override the existing file. - **--force**: tells the generator to override the existing file.
- **--laravel**: create Laravel style routes
### Multiple Resources From File ### Multiple Resources From File
The `wn:resources` (note the "s" in "resources") command takes the generation process to an other level by parsing a file and generating multiple resources based on it. The syntax is The `wn:resources` (note the "s" in "resources") command takes the generation process to an other level by parsing a file and generating multiple resources based on it. The syntax is
@ -595,6 +614,9 @@ The file given to the command should be a valid YAML file ( for the moment, supp
- **--path**: Defines where to store the model files as well as their namespace. - **--path**: Defines where to store the model files as well as their namespace.
- **--laravel**: create Laravel style routes
```yaml ```yaml
--- ---
Store: Store:

View File

@ -1,5 +1,5 @@
{ {
"name": "wn/lumen-generators", "name": "zorgcc/lumen-generators",
"description": "A collection of generators for Lumen and Laravel 5.", "description": "A collection of generators for Lumen and Laravel 5.",
"keywords": ["lumen", "laravel", "rest", "api", "generators"], "keywords": ["lumen", "laravel", "rest", "api", "generators"],
"license": "MIT", "license": "MIT",
@ -10,10 +10,10 @@
} }
], ],
"require": { "require": {
"php": ">=5.5.0", "php": "^7.2",
"illuminate/console": "^5.1", "illuminate/console": "^5.1|^6",
"illuminate/filesystem": "^5.1", "illuminate/filesystem": "^5.1|^6",
"fzaninotto/faker": "^1.5" "fzaninotto/faker": "^1.5"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -1,7 +1,11 @@
/vendor /vendor
.env .env
codecept.phar
tests/_output/* tests/_output/*
composer.lock composer.lock
tests/_output/* tests/_output/*
codecept.phar

View File

@ -1,5 +1,16 @@
<?php <?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get("/", function () use ($app) { $app->get("/", function () use ($app) {
return $app->welcome(); return $app->welcome();
}); });

View File

@ -11,6 +11,14 @@ echo "<?php
return \$app->welcome(); return \$app->welcome();
});" > app/Http/routes.php });" > app/Http/routes.php
echo "<?php
/*
|------------------------------------------
| ***** DUMMY ROUTES FOR TESTING ONLY *****
|------------------------------------------
*/
" > routes/api.php
# Controllers # Controllers
rm app/Http/Controllers/*.php 2> /dev/null rm app/Http/Controllers/*.php 2> /dev/null
echo "<?php echo "<?php

View File

@ -1,5 +1,16 @@
<?php <?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function ($faker) { $factory->define(App\User::class, function ($faker) {
return [ return [
'name' => $faker->name, 'name' => $faker->name,
@ -8,4 +19,3 @@ $factory->define(App\User::class, function ($faker) {
'remember_token' => str_random(10), 'remember_token' => str_random(10),
]; ];
}); });

View File

@ -0,0 +1,26 @@
---
Author:
belongsTo: book
fields:
name:
schema: string
tags: fillable
Book:
belongsTo: librarys # Yes I know it's misspelled...
hasOne: author
fields:
title:
schema: string
tags: fillable
published:
schema: date
tags: fillable
Library:
hasMany: books
fields:
name:
schema: string
tags: fillable
address:
schema: string
tags: fillable

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 6172d62f52ee53bf8d6f975a52df4f0d <?php //[STAMP] d6606f78456705b0875c6b8343fc6a4a
namespace _generated; namespace _generated;
// This class was automatically generated by build task // This class was automatically generated by build task
@ -17,6 +17,22 @@ trait AcceptanceTesterActions
abstract protected function getScenario(); abstract protected function getScenario();
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that array contains subset.
*
* @param array $subset
* @param array $array
* @param bool $strict
* @param string $message
* @see \Codeception\Module::assertArraySubset()
*/
public function assertArraySubset($subset, $array, $strict = null, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@ -95,7 +111,7 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* * @param $regex
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Cli::seeShellOutputMatches() * @see \Codeception\Module\Cli::seeShellOutputMatches()
*/ */
@ -105,7 +121,7 @@ trait AcceptanceTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* * @param $regex
* @see \Codeception\Module\Cli::seeShellOutputMatches() * @see \Codeception\Module\Cli::seeShellOutputMatches()
*/ */
public function seeShellOutputMatches($regex) { public function seeShellOutputMatches($regex) {
@ -113,13 +129,83 @@ trait AcceptanceTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks result code
*
* ```php
* <?php
* $I->seeResultCodeIs(0);
* ```
*
* @param $code
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Cli::seeResultCodeIs()
*/
public function canSeeResultCodeIs($code) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResultCodeIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks result code
*
* ```php
* <?php
* $I->seeResultCodeIs(0);
* ```
*
* @param $code
* @see \Codeception\Module\Cli::seeResultCodeIs()
*/
public function seeResultCodeIs($code) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResultCodeIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks result code
*
* ```php
* <?php
* $I->seeResultCodeIsNot(0);
* ```
*
* @param $code
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Cli::seeResultCodeIsNot()
*/
public function canSeeResultCodeIsNot($code) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResultCodeIsNot', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks result code
*
* ```php
* <?php
* $I->seeResultCodeIsNot(0);
* ```
*
* @param $code
* @see \Codeception\Module\Cli::seeResultCodeIsNot()
*/
public function seeResultCodeIsNot($code) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResultCodeIsNot', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Enters a directory In local filesystem. * Enters a directory In local filesystem.
* Project root directory is used by default * Project root directory is used by default
* *
* @param $path * @param string $path
* @see \Codeception\Module\Filesystem::amInPath() * @see \Codeception\Module\Filesystem::amInPath()
*/ */
public function amInPath($path) { public function amInPath($path) {
@ -141,7 +227,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $filename * @param string $filename
* @see \Codeception\Module\Filesystem::openFile() * @see \Codeception\Module\Filesystem::openFile()
*/ */
public function openFile($filename) { public function openFile($filename) {
@ -160,7 +246,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $filename * @param string $filename
* @see \Codeception\Module\Filesystem::deleteFile() * @see \Codeception\Module\Filesystem::deleteFile()
*/ */
public function deleteFile($filename) { public function deleteFile($filename) {
@ -179,7 +265,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $dirname * @param string $dirname
* @see \Codeception\Module\Filesystem::deleteDir() * @see \Codeception\Module\Filesystem::deleteDir()
*/ */
public function deleteDir($dirname) { public function deleteDir($dirname) {
@ -198,8 +284,8 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $src * @param string $src
* @param $dst * @param string $dst
* @see \Codeception\Module\Filesystem::copyDir() * @see \Codeception\Module\Filesystem::copyDir()
*/ */
public function copyDir($src, $dst) { public function copyDir($src, $dst) {
@ -221,7 +307,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Filesystem::seeInThisFile() * @see \Codeception\Module\Filesystem::seeInThisFile()
*/ */
@ -242,7 +328,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @see \Codeception\Module\Filesystem::seeInThisFile() * @see \Codeception\Module\Filesystem::seeInThisFile()
*/ */
public function seeInThisFile($text) { public function seeInThisFile($text) {
@ -298,7 +384,7 @@ trait AcceptanceTesterActions
* *
* Checks that contents of currently opened file matches $regex * Checks that contents of currently opened file matches $regex
* *
* @param $regex * @param string $regex
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Filesystem::seeThisFileMatches() * @see \Codeception\Module\Filesystem::seeThisFileMatches()
*/ */
@ -310,7 +396,7 @@ trait AcceptanceTesterActions
* *
* Checks that contents of currently opened file matches $regex * Checks that contents of currently opened file matches $regex
* *
* @param $regex * @param string $regex
* @see \Codeception\Module\Filesystem::seeThisFileMatches() * @see \Codeception\Module\Filesystem::seeThisFileMatches()
*/ */
public function seeThisFileMatches($regex) { public function seeThisFileMatches($regex) {
@ -333,7 +419,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Filesystem::seeFileContentsEqual() * @see \Codeception\Module\Filesystem::seeFileContentsEqual()
*/ */
@ -355,7 +441,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @see \Codeception\Module\Filesystem::seeFileContentsEqual() * @see \Codeception\Module\Filesystem::seeFileContentsEqual()
*/ */
public function seeFileContentsEqual($text) { public function seeFileContentsEqual($text) {
@ -375,7 +461,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Filesystem::dontSeeInThisFile() * @see \Codeception\Module\Filesystem::dontSeeInThisFile()
*/ */
@ -394,7 +480,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $text * @param string $text
* @see \Codeception\Module\Filesystem::dontSeeInThisFile() * @see \Codeception\Module\Filesystem::dontSeeInThisFile()
*/ */
public function dontSeeInThisFile($text) { public function dontSeeInThisFile($text) {
@ -425,7 +511,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $filename * @param string $filename
* @param string $path * @param string $path
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Filesystem::seeFileFound() * @see \Codeception\Module\Filesystem::seeFileFound()
@ -445,7 +531,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $filename * @param string $filename
* @param string $path * @param string $path
* @see \Codeception\Module\Filesystem::seeFileFound() * @see \Codeception\Module\Filesystem::seeFileFound()
*/ */
@ -459,7 +545,7 @@ trait AcceptanceTesterActions
* *
* Checks if file does not exist in path * Checks if file does not exist in path
* *
* @param $filename * @param string $filename
* @param string $path * @param string $path
* Conditional Assertion: Test won't be stopped on fail * Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Filesystem::dontSeeFileFound() * @see \Codeception\Module\Filesystem::dontSeeFileFound()
@ -472,7 +558,7 @@ trait AcceptanceTesterActions
* *
* Checks if file does not exist in path * Checks if file does not exist in path
* *
* @param $filename * @param string $filename
* @param string $path * @param string $path
* @see \Codeception\Module\Filesystem::dontSeeFileFound() * @see \Codeception\Module\Filesystem::dontSeeFileFound()
*/ */
@ -492,7 +578,7 @@ trait AcceptanceTesterActions
* ?> * ?>
* ``` * ```
* *
* @param $dirname * @param string $dirname
* @see \Codeception\Module\Filesystem::cleanDir() * @see \Codeception\Module\Filesystem::cleanDir()
*/ */
public function cleanDir($dirname) { public function cleanDir($dirname) {
@ -505,8 +591,8 @@ trait AcceptanceTesterActions
* *
* Saves contents to file * Saves contents to file
* *
* @param $filename * @param string $filename
* @param $contents * @param string $contents
* @see \Codeception\Module\Filesystem::writeToFile() * @see \Codeception\Module\Filesystem::writeToFile()
*/ */
public function writeToFile($filename, $contents) { public function writeToFile($filename, $contents) {

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 113b78942a9c8ce85a7c18397003b17c <?php //[STAMP] d2a298893573661fdbd787dcfa27a7b0
namespace _generated; namespace _generated;
// This class was automatically generated by build task // This class was automatically generated by build task
@ -15,4 +15,18 @@ trait FunctionalTesterActions
abstract protected function getScenario(); abstract protected function getScenario();
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that array contains subset.
*
* @param array $subset
* @param array $array
* @param bool $strict
* @param string $message
* @see \Codeception\Module::assertArraySubset()
*/
public function assertArraySubset($subset, $array, $strict = null, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
}
} }

View File

@ -1,4 +1,4 @@
<?php //[STAMP] afa4f0350422fae145b4236dce66191a <?php //[STAMP] 1467e0d5027bbc2413077351642a21f3
namespace _generated; namespace _generated;
// This class was automatically generated by build task // This class was automatically generated by build task
@ -19,14 +19,29 @@ trait UnitTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Checks that two variables are equal. * Checks that two variables are equal. If you're comparing floating-point values,
* you can specify the optional "delta" parameter which dictates how great of a precision
* error are you willing to tolerate in order to consider the two values equal.
*
* Regular example:
* ```php
* <?php
* $I->assertEquals($element->getChildrenCount(), 5);
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->assertEquals($calculator->add(0.1, 0.2), 0.3, 'Calculator should add the two numbers correctly.', 0.01);
* ```
* *
* @param $expected * @param $expected
* @param $actual * @param $actual
* @param string $message * @param string $message
* @param float $delta
* @see \Codeception\Module\Asserts::assertEquals() * @see \Codeception\Module\Asserts::assertEquals()
*/ */
public function assertEquals($expected, $actual, $message = null) { public function assertEquals($expected, $actual, $message = null, $delta = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
} }
@ -34,14 +49,29 @@ trait UnitTesterActions
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
* Checks that two variables are not equal * Checks that two variables are not equal. If you're comparing floating-point values,
* you can specify the optional "delta" parameter which dictates how great of a precision
* error are you willing to tolerate in order to consider the two values not equal.
*
* Regular example:
* ```php
* <?php
* $I->assertNotEquals($element->getChildrenCount(), 0);
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->assertNotEquals($calculator->add(0.1, 0.2), 0.4, 'Calculator should add the two numbers correctly.', 0.01);
* ```
* *
* @param $expected * @param $expected
* @param $actual * @param $actual
* @param string $message * @param string $message
* @param float $delta
* @see \Codeception\Module\Asserts::assertNotEquals() * @see \Codeception\Module\Asserts::assertNotEquals()
*/ */
public function assertNotEquals($expected, $actual, $message = null) { public function assertNotEquals($expected, $actual, $message = null, $delta = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args()));
} }
@ -54,7 +84,6 @@ trait UnitTesterActions
* @param $expected * @param $expected
* @param $actual * @param $actual
* @param string $message * @param string $message
* @return mixed|void
* @see \Codeception\Module\Asserts::assertSame() * @see \Codeception\Module\Asserts::assertSame()
*/ */
public function assertSame($expected, $actual, $message = null) { public function assertSame($expected, $actual, $message = null) {
@ -197,6 +226,36 @@ trait UnitTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a string starts with the given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @see \Codeception\Module\Asserts::assertStringStartsWith()
*/
public function assertStringStartsWith($prefix, $string, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a string doesn't start with the given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @see \Codeception\Module\Asserts::assertStringStartsNotWith()
*/
public function assertStringStartsNotWith($prefix, $string, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *
@ -373,6 +432,22 @@ trait UnitTesterActions
} }
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that array contains subset.
*
* @param array $subset
* @param array $array
* @param bool $strict
* @param string $message
* @see \Codeception\Module::assertArraySubset()
*/
public function assertArraySubset($subset, $array, $strict = null, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
}
/** /**
* [!] Method is generated. Documentation taken from corresponding module. * [!] Method is generated. Documentation taken from corresponding module.
* *

View File

@ -0,0 +1,136 @@
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Generate RESTful resources from a file');
$I->writeToFile('database/database.sqlite', '');
$I->runShellCommand('php artisan wn:resources tests/_data/ResourcesTest.yml');
// Checking the model
$I->seeInShellOutput('Author model generated');
$I->seeInShellOutput('Book model generated');
$I->seeInShellOutput('Library model generated');
$I->seeFileFound('./app/Author.php');
$I->seeFileFound('./app/Book.php');
$I->seeFileFound('./app/Library.php');
$I->deleteFile('./app/Author.php');
$I->deleteFile('./app/Book.php');
$I->deleteFile('./app/Library.php');
// Checking the migration
$I->seeInShellOutput('authors migration generated');
$I->seeInShellOutput('books migration generated');
$I->seeInShellOutput('libraries migration generated');
// Can't check for specific file names, so we'll just strip the directory
$I->cleanDir('database/migrations');
$I->writeToFile('database/migrations/.gitkeep', '');
// Checking the RESTActions trait
$I->seeFileFound('./app/Http/Controllers/RESTActions.php');
$I->deleteFile('./app/Http/Controllers/RESTActions.php');
// Checking the controller
$I->seeInShellOutput('AuthorsController generated');
$I->seeInShellOutput('LibrariesController generated');
$I->seeInShellOutput('BooksController generated');
$I->seeFileFound('./app/Http/Controllers/AuthorsController.php');
$I->seeFileFound('./app/Http/Controllers/LibrariesController.php');
$I->seeFileFound('./app/Http/Controllers/BooksController.php');
$I->deleteFile('./app/Http/Controllers/AuthorsController.php');
$I->deleteFile('./app/Http/Controllers/LibrariesController.php');
$I->deleteFile('./app/Http/Controllers/BooksController.php');
// Checking routes
$I->openFile('./app/Http/routes.php');
$I->seeInThisFile('
$app->get(\'author\', \'AuthorsController@all\');
$app->get(\'author/{id}\', \'AuthorsController@get\');
$app->post(\'author\', \'AuthorsController@add\');
$app->put(\'author/{id}\', \'AuthorsController@put\');
$app->delete(\'author/{id}\', \'AuthorsController@remove\');');
$I->seeInThisFile('
$app->get(\'book\', \'BooksController@all\');
$app->get(\'book/{id}\', \'BooksController@get\');
$app->post(\'book\', \'BooksController@add\');
$app->put(\'book/{id}\', \'BooksController@put\');
$app->delete(\'book/{id}\', \'BooksController@remove\');');
$I->seeInThisFile('
$app->get(\'library\', \'LibrariesController@all\');
$app->get(\'library/{id}\', \'LibrariesController@get\');
$app->post(\'library\', \'LibrariesController@add\');
$app->put(\'library/{id}\', \'LibrariesController@put\');
$app->delete(\'library/{id}\', \'LibrariesController@remove\');');
$I->writeToFile('./app/Http/routes.php', '<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get("/", function () use ($app) {
return $app->welcome();
});
');
// Checking model factory
// $I->openFile('./database/factories/ModelFactory.php');
// $I->seeInThisFile(
// "/**
// * Factory definition for model App\TaskCategory.
// */
// \$factory->define(App\TaskCategory::class, function (\$faker) {
// return [
// 'name' => \$faker->word,
// 'descr' => \$faker->paragraph,
// 'due' => \$faker->date,
// ];
// });");
$I->writeToFile('./database/factories/ModelFactory.php', "<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
\$factory->define(App\User::class, function (\$faker) {
return [
'name' => \$faker->name,
'email' => \$faker->email,
'password' => str_random(10),
'remember_token' => str_random(10),
];
});
");
$I->deleteFile('database/database.sqlite');
// Checking database seeder
// $I->openFile('./database/seeds/TaskCategoriesTableSeeder.php');
// $I->seeInThisFile('
// use Illuminate\Database\Seeder;
// class TaskCategoriesTableSeeder extends Seeder
// {
// public function run()
// {
// factory(App\TaskCategory::class, 10)->create();
// }
// }');
// $I->deleteFile('./database/seeds/TaskCategoriesTableSeeder.php');

View File

@ -0,0 +1,124 @@
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Generate RESTful resources from a file with Laravel Routes');
$I->writeToFile('database/database.sqlite', '');
$I->runShellCommand('php artisan wn:resources tests/_data/ResourcesTest.yml --laravel=true');
// Checking the model
$I->seeInShellOutput('Author model generated');
$I->seeInShellOutput('Book model generated');
$I->seeInShellOutput('Library model generated');
$I->seeFileFound('./app/Author.php');
$I->seeFileFound('./app/Book.php');
$I->seeFileFound('./app/Library.php');
$I->deleteFile('./app/Author.php');
$I->deleteFile('./app/Book.php');
$I->deleteFile('./app/Library.php');
// Checking the migration
$I->seeInShellOutput('authors migration generated');
$I->seeInShellOutput('books migration generated');
$I->seeInShellOutput('libraries migration generated');
// Can't check for specific file names, so we'll just strip the directory
$I->cleanDir('database/migrations');
$I->writeToFile('database/migrations/.gitkeep', '');
// Checking the RESTActions trait
$I->seeFileFound('./app/Http/Controllers/RESTActions.php');
$I->deleteFile('./app/Http/Controllers/RESTActions.php');
// Checking the controller
$I->seeInShellOutput('AuthorsController generated');
$I->seeInShellOutput('LibrariesController generated');
$I->seeInShellOutput('BooksController generated');
$I->seeFileFound('./app/Http/Controllers/AuthorsController.php');
$I->seeFileFound('./app/Http/Controllers/LibrariesController.php');
$I->seeFileFound('./app/Http/Controllers/BooksController.php');
$I->deleteFile('./app/Http/Controllers/AuthorsController.php');
$I->deleteFile('./app/Http/Controllers/LibrariesController.php');
$I->deleteFile('./app/Http/Controllers/BooksController.php');
$I->seeFileFound('./routes/api.php');
$I->seeInThisFile('
Route::get(\'author\', \'AuthorsController@all\');
Route::get(\'author/{id}\', \'AuthorsController@get\');
Route::post(\'author\', \'AuthorsController@add\');
Route::put(\'author/{id}\', \'AuthorsController@put\');
Route::delete(\'author/{id}\', \'AuthorsController@remove\');');
$I->seeInThisFile('
Route::get(\'book\', \'BooksController@all\');
Route::get(\'book/{id}\', \'BooksController@get\');
Route::post(\'book\', \'BooksController@add\');
Route::put(\'book/{id}\', \'BooksController@put\');
Route::delete(\'book/{id}\', \'BooksController@remove\');');
$I->seeInThisFile('
Route::get(\'library\', \'LibrariesController@all\');
Route::get(\'library/{id}\', \'LibrariesController@get\');
Route::post(\'library\', \'LibrariesController@add\');
Route::put(\'library/{id}\', \'LibrariesController@put\');
Route::delete(\'library/{id}\', \'LibrariesController@remove\');');
$I->writeToFile('./app/Http/routes.php', '<?php
/*
|------------------------------------------
| ***** DUMMY ROUTES FOR TESTING ONLY *****
|------------------------------------------
*/
');
// Checking model factory
// $I->openFile('./database/factories/ModelFactory.php');
// $I->seeInThisFile(
// "/**
// * Factory definition for model App\TaskCategory.
// */
// \$factory->define(App\TaskCategory::class, function (\$faker) {
// return [
// 'name' => \$faker->word,
// 'descr' => \$faker->paragraph,
// 'due' => \$faker->date,
// ];
// });");
$I->writeToFile('./database/factories/ModelFactory.php', "<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
\$factory->define(App\User::class, function (\$faker) {
return [
'name' => \$faker->name,
'email' => \$faker->email,
'password' => str_random(10),
'remember_token' => str_random(10),
];
});
");
$I->deleteFile('database/database.sqlite');
// Checking database seeder
// $I->openFile('./database/seeds/TaskCategoriesTableSeeder.php');
// $I->seeInThisFile('
// use Illuminate\Database\Seeder;
// class TaskCategoriesTableSeeder extends Seeder
// {
// public function run()
// {
// factory(App\TaskCategory::class, 10)->create();
// }
// }');
// $I->deleteFile('./database/seeds/TaskCategoriesTableSeeder.php');

View File

@ -62,7 +62,9 @@ $app->get("/", function () use ($app) {
$I->wantTo('run wn:routes in Lumen 5.3+'); $I->wantTo('run wn:routes in Lumen 5.3+');
mkdir('./routes'); if(!file_exists('./routes')) {
mkdir('./routes');
}
$I->writeToFile('./routes/web.php', '<?php $I->writeToFile('./routes/web.php', '<?php
/* /*

View File

@ -1,12 +1,15 @@
<?php namespace Wn\Generators\Commands; <?php namespace Wn\Generators\Commands;
use InvalidArgumentException;
class ControllerCommand extends BaseCommand { class ControllerCommand extends BaseCommand {
protected $signature = 'wn:controller protected $signature = 'wn:controller
{model : Name of the model (with namespace if not App)} {model : Name of the model (with namespace if not App)}
{--no-routes= : without routes} {--no-routes= : without routes}
{--force= : override the existing files} {--force= : override the existing files}
{--laravel : Use Laravel style route definitions}
'; ';
protected $description = 'Generates RESTful controller using the RESTActions trait'; protected $description = 'Generates RESTful controller using the RESTActions trait';
@ -31,12 +34,17 @@ class ControllerCommand extends BaseCommand {
->get(); ->get();
$this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}");
if(! $this->option('no-routes')){ if(! $this->option('no-routes')){
$this->call('wn:route', [ $options = [
'resource' => snake_case($name, '-'), 'resource' => snake_case($name, '-'),
'--controller' => $controller '--controller' => $controller,
]); ];
if ($this->option('laravel')) {
$options['--laravel'] = true;
}
$this->call('wn:route', $options);
} }
} }

View File

@ -3,7 +3,7 @@
class MigrationCommand extends BaseCommand { class MigrationCommand extends BaseCommand {
protected $signature = 'wn:migration protected $signature = 'wn:migration
{table : The table name.} {table : The table name.}
{--schema= : the schema.} {--schema= : the schema.}
{--add= : specifies additional columns like timestamps, softDeletes, rememberToken and nullableTimestamps.} {--add= : specifies additional columns like timestamps, softDeletes, rememberToken and nullableTimestamps.}
@ -12,15 +12,16 @@ class MigrationCommand extends BaseCommand {
{--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} {--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}
{--force= : override the existing files} {--force= : override the existing files}
'; ';
// {action : One of create, add, remove or drop options.} // {action : One of create, add, remove or drop options.}
// The action is only create for the moment // The action is only create for the moment
protected $description = 'Generates a migration to create a table with schema'; protected $description = 'Generates a migration to create a table with schema';
public function handle() public function handle()
{ {
$table = $this->argument('table'); $table = $this->argument('table');
$name = 'Create' . ucwords(camel_case($table)); $name = 'Create' . ucwords(camel_case($table));
$snakeName = snake_case($name);
$content = $this->getTemplate('migration') $content = $this->getTemplate('migration')
->with([ ->with([
@ -34,12 +35,26 @@ class MigrationCommand extends BaseCommand {
$file = $this->option('file'); $file = $this->option('file');
if(! $file){ if(! $file){
$file = date('Y_m_d_His_') . snake_case($name) . '_table'; $file = date('Y_m_d_His_') . $snakeName . '_table';
$this->deleteOldMigration($snakeName);
}else{
$this->deleteOldMigration($file);
} }
$this->save($content, "./database/migrations/{$file}.php", "{$table} migration"); $this->save($content, "./database/migrations/{$file}.php", "{$table} migration");
} }
protected function deleteOldMigration($fileName)
{
foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo){
if($fileInfo->isDot()) continue;
if(strpos($fileInfo->getFilename(), $fileName) !== FALSE){
unlink($fileInfo->getPathname());
}
}
}
protected function getSchema() protected function getSchema()
{ {
$schema = $this->option('schema'); $schema = $this->option('schema');
@ -127,20 +142,20 @@ class MigrationCommand extends BaseCommand {
if($key['on_delete']){ if($key['on_delete']){
$constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint') $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint')
->with([ ->with([
'event' => 'Delete', 'event' => 'Delete',
'action' => $key['on_delete'] 'action' => $key['on_delete']
]) ])
->get(); ->get();
} }
if($key['on_update']){ if($key['on_update']){
$constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint') $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint')
->with([ ->with([
'event' => 'Update', 'event' => 'Update',
'action' => $key['on_update'] 'action' => $key['on_update']
]) ])
->get(); ->get();
} }
return $constraint . ';'; return $constraint . ';';

View File

@ -1,6 +1,8 @@
<?php namespace Wn\Generators\Commands; <?php namespace Wn\Generators\Commands;
use InvalidArgumentException;
class ResourceCommand extends BaseCommand { class ResourceCommand extends BaseCommand {
protected $signature = 'wn:resource protected $signature = 'wn:resource
@ -15,6 +17,7 @@ class ResourceCommand extends BaseCommand {
{--path=app : where to store the model file.} {--path=app : where to store the model file.}
{--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} {--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}
{--force= : override the existing files} {--force= : override the existing files}
{--laravel= : Use Laravel style route definitions}
'; ';
protected $description = 'Generates a model, migration, controller and routes for RESTful resource'; protected $description = 'Generates a model, migration, controller and routes for RESTful resource';
@ -61,13 +64,16 @@ class ResourceCommand extends BaseCommand {
if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){ if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
$this->call('wn:controller:rest-actions'); $this->call('wn:controller:rest-actions');
} }
// generating the controller and routes // generating the controller and routes
$this->call('wn:controller', [ $controllerOptions = [
'model' => $modelName, 'model' => $modelName,
'--force' => $this->option('force'), '--force' => $this->option('force'),
'--no-routes' => false '--no-routes' => false,
]); ];
if ($this->option('laravel')) {
$controllerOptions['--laravel'] = true;
}
$this->call('wn:controller', $controllerOptions);
// generating model factory // generating model factory
$this->call('wn:factory', [ $this->call('wn:factory', [

View File

@ -1,5 +1,6 @@
<?php namespace Wn\Generators\Commands; <?php namespace Wn\Generators\Commands;
use InvalidArgumentException;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
@ -9,6 +10,8 @@ class ResourcesCommand extends BaseCommand {
{file : Path to the file containing resources declarations} {file : Path to the file containing resources declarations}
{--path=app : where to store the model files.} {--path=app : where to store the model files.}
{--force= : override the existing files} {--force= : override the existing files}
{--laravel= : Use Laravel style route definitions}
'; ';
protected $description = 'Generates multiple resources from a file'; protected $description = 'Generates multiple resources from a file';
@ -20,10 +23,14 @@ class ResourcesCommand extends BaseCommand {
$content = $this->fs->get($this->argument('file')); $content = $this->fs->get($this->argument('file'));
$content = Yaml::parse($content); $content = Yaml::parse($content);
$modelIndex = 0;
foreach ($content as $model => $i){ foreach ($content as $model => $i){
$i = $this->getResourceParams($model, $i); $i = $this->getResourceParams($model, $i);
$migrationName = 'Create' . ucwords(str_plural($i['name']));
$migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex , 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table';
$this->call('wn:resource', [
$options = [
'name' => $i['name'], 'name' => $i['name'],
'fields' => $i['fields'], 'fields' => $i['fields'],
'--add' => $i['add'], '--add' => $i['add'],
@ -32,8 +39,15 @@ class ResourcesCommand extends BaseCommand {
'--belongs-to' => $i['belongsTo'], '--belongs-to' => $i['belongsTo'],
'--belongs-to-many' => $i['belongsToMany'], '--belongs-to-many' => $i['belongsToMany'],
'--path' => $this->option('path'), '--path' => $this->option('path'),
'--force' => $this->option('force') '--force' => $this->option('force'),
]); '--migration-file' => $migrationFile
];
if ($this->option('laravel')) {
$options['--laravel'] = true;
}
$this->call('wn:resource', $options);
$modelIndex++;
} }
// $this->call('migrate'); // actually needed for pivot seeders ! // $this->call('migrate'); // actually needed for pivot seeders !

View File

@ -1,31 +1,66 @@
<?php namespace Wn\Generators\Commands; <?php namespace Wn\Generators\Commands;
use InvalidArgumentException;
class RouteCommand extends BaseCommand { class RouteCommand extends BaseCommand {
protected $signature = 'wn:route protected $signature = 'wn:route
{resource : Name of the resource.} {resource : Name of the resource.}
{--controller= : Name of the RESTful controller.}'; {--controller= : Name of the RESTful controller.}
{--laravel= : Use Laravel style route definitions}
';
protected $description = 'Generates RESTful routes.'; protected $description = 'Generates RESTful routes.';
public function handle() public function handle()
{ {
$resource = $this->argument('resource'); $resource = $this->argument('resource');
$laravelRoutes = $this->option('laravel');
$templateFile = 'routes';
$routesPath = 'routes/web.php';
if ($laravelRoutes) {
$templateFile = 'routes-laravel';
$routesPath = 'routes/api.php';
if (!$this->fs->isFile($routesPath)) {
if (!$this->fs->isDirectory('./routes')) {
$this->fs->makeDirectory('./routes');
}
$this->fs->put($routesPath, "
<?php
$routesPath = './routes/web.php'; use Illuminate\Http\Request;
if (! $this->fs->exists($routesPath))
$routesPath = './app/Http/routes.php'; /*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the \"api\" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request \$request) {
return \$request->user();
});
");
}
}
if (!$this->fs->isFile($routesPath)) {
$routesPath = 'app/Http/routes.php';
}
$content = $this->fs->get($routesPath); $content = $this->fs->get($routesPath);
$content .= PHP_EOL . $this->getTemplate('routes') $content .= PHP_EOL . $this->getTemplate($templateFile)
->with([ ->with([
'resource' => $resource, 'resource' => $resource,
'controller' => $this->getController() 'controller' => $this->getController()
]) ])
->get(); ->get();
$this->save($content, $routesPath, "{$resource} routes", true); $this->save($content, $routesPath, "{$resource} routes", true);
} }

View File

@ -2,7 +2,7 @@
class {{name}} extends Controller { class {{name}} extends Controller {
const MODEL = "{{model}}"; const MODEL = '{{model}}';
use RESTActions; use RESTActions;

View File

@ -53,6 +53,12 @@ trait RESTActions {
protected function respond($status, $data = []) protected function respond($status, $data = [])
{ {
if($status == Response::HTTP_NO_CONTENT){
return response(null,Response::HTTP_NO_CONTENT);
}
if($status == Response::HTTP_NOT_FOUND){
return response(['message'=>'resource not found'],Response::HTTP_NOT_FOUND);
}
return response()->json($data, $status); return response()->json($data, $status);
} }

View File

@ -0,0 +1,8 @@
/**
* Routes for resource {{resource}}
*/
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');

View File

@ -1,8 +1,8 @@
/** /**
* Routes for resource {{resource}} * Routes for resource {{resource}}
*/ */
$app->get('{{resource}}', '{{controller}}@all'); $router->get('{{resource}}', '{{controller}}@all');
$app->get('{{resource}}/{id}', '{{controller}}@get'); $router->get('{{resource}}/{id}', '{{controller}}@get');
$app->post('{{resource}}', '{{controller}}@add'); $router->post('{{resource}}', '{{controller}}@add');
$app->put('{{resource}}/{id}', '{{controller}}@put'); $router->put('{{resource}}/{id}', '{{controller}}@put');
$app->delete('{{resource}}/{id}', '{{controller}}@remove'); $router->delete('{{resource}}/{id}', '{{controller}}@remove');