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

Resource creation damages artisan #47

Closed
msetibr opened this issue Oct 17, 2017 · 2 comments
Closed

Resource creation damages artisan #47

msetibr opened this issue Oct 17, 2017 · 2 comments

Comments

@msetibr
Copy link

msetibr commented Oct 17, 2017

After executing a standard artisan wn:resource command, artisan console becomes unusable.

Example:
>php artisan list
Laravel Framework Lumen (5.5.2) (Laravel Components 5.5.*)

Usage:
command [options] [arguments]

Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
help Displays help for a command
list Lists commands
migrate Run the database migrations
auth
auth:clear-resets Flush expired password reset tokens
cache
cache:clear Flush the application cache
cache:forget Remove an item from the cache
cache:table Create a migration for the cache database table
db
db:seed Seed the database with records
make
make:migration Create a new migration file
make:seeder Create a new seeder class
migrate
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
queue
queue:failed List all of the failed queue jobs
queue:failed-table Create a migration for the failed queue jobs database table
queue:flush Flush all of the failed queue jobs
queue:forget Delete a failed queue job
queue:listen Listen to a given queue
queue:restart Restart queue worker daemons after their current job
queue:retry Retry a failed queue job
queue:table Create a migration for the queue jobs database table
queue:work Start processing jobs on the queue as a daemon
schedule
schedule:run Run the scheduled commands
wn
wn:controller Generates RESTful controller using the RESTActions trait
wn:controller:rest-actions Generates REST actions trait to use into controllers
wn:factory Generates a model factory
wn:migration Generates a migration to create a table with schema
wn:model Generates a model class for a RESTfull resource
wn:pivot-table Generates creation migration for a pivot table
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.

>php artisan wn:resource State "name;string.200;required;fillable initials;string.2;required;fillable"
State model generated !
States migration generated !
StatesController generated !
state routes generated !
App\State factory generated !

>php artisan list

[ErrorException]
Undefined variable: app

@msetibr
Copy link
Author

msetibr commented Oct 17, 2017

The problem is in routes.wnt template in vendor/wn/lumen-generators/templates

$app variable MUST be replaced by $router:
/**

  • Routes for resource {{resource}}
    */
    $app->get('{{resource}}/{id}', '{{controller}}@get');
    $app->post('{{resource}}', '{{controller}}@add');
    $app->get('{{resource}}', '{{controller}}@ALL');
    $app->put('{{resource}}/{id}', '{{controller}}@put');
    $app->delete('{{resource}}/{id}', '{{controller}}@remove');

/**

  • Routes for resource {{resource}}
    */
    $router->get('{{resource}}/{id}', '{{controller}}@get');
    $router->post('{{resource}}', '{{controller}}@add');
    $router->get('{{resource}}', '{{controller}}@ALL');
    $router->put('{{resource}}/{id}', '{{controller}}@put');
    $router->delete('{{resource}}/{id}', '{{controller}}@remove');

davidporos92 added a commit to davidporos92/lumen-generators that referenced this issue Oct 20, 2017
@webNeat
Copy link
Owner

webNeat commented Oct 22, 2017

Fixed on 8ee7bbe by @AfzalH

@webNeat webNeat closed this as completed Oct 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants