mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2025-04-10 03:10:04 +03:00
- Bug fixed: [Undefined index: factory](https://github.com/webNeat/lumen-generators/issues/14) - Feature added: [Check if file already exists before generating it](https://github.com/webNeat/lumen-generators/issues/11) - Feature added: [Support for additional columns like nullableTimestamps() and softDeletes() in migrations](https://github.com/webNeat/lumen-generators/issues/12) - Feature added: [Specifying namespace for `wn:resource` and `wn:resources`](https://github.com/webNeat/lumen-generators/issues/18)
37 lines
994 B
PHP
37 lines
994 B
PHP
<?php namespace Wn\Generators\Commands;
|
|
|
|
|
|
class RouteCommand extends BaseCommand {
|
|
|
|
protected $signature = 'wn:route
|
|
{resource : Name of the resource.}
|
|
{--controller= : Name of the RESTful controller.}';
|
|
|
|
protected $description = 'Generates RESTful routes.';
|
|
|
|
public function handle()
|
|
{
|
|
$resource = $this->argument('resource');
|
|
|
|
$content = $this->fs->get('./app/Http/routes.php');
|
|
|
|
$content .= PHP_EOL . $this->getTemplate('routes')
|
|
->with([
|
|
'resource' => $resource,
|
|
'controller' => $this->getController()
|
|
])
|
|
->get();
|
|
|
|
$this->save($content, './app/Http/routes.php', "{$resource} routes", true);
|
|
}
|
|
|
|
protected function getController()
|
|
{
|
|
$controller = $this->option('controller');
|
|
if(! $controller){
|
|
$controller = ucwords(str_plural(camel_case($this->argument('resource')))) . 'Controller';
|
|
}
|
|
return $controller;
|
|
}
|
|
|
|
} |