mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2024-12-26 14:05:29 +03:00
Finalize testing
This commit is contained in:
parent
5e2c21855e
commit
a951151697
@ -1,5 +1,16 @@
|
||||
<?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();
|
||||
});
|
||||
|
@ -1,5 +1,16 @@
|
||||
<?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,
|
||||
@ -8,4 +19,3 @@ $factory->define(App\User::class, function ($faker) {
|
||||
'remember_token' => str_random(10),
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -39,7 +39,7 @@ $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->seeFileFound('./routes/api.php');
|
||||
|
||||
$I->seeInThisFile('
|
||||
Route::get(\'author\', \'AuthorsController@all\');
|
||||
|
@ -38,14 +38,8 @@ class ControllerCommand extends BaseCommand {
|
||||
$options = [
|
||||
'resource' => snake_case($name, '-'),
|
||||
'--controller' => $controller,
|
||||
'--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false
|
||||
];
|
||||
// try {
|
||||
// if($this->option('laravel')) {
|
||||
// $options['--laravel'] = true;
|
||||
// };
|
||||
// } catch (InvalidArgumentException $e) {
|
||||
// // Do nothing
|
||||
// }
|
||||
|
||||
$this->call('wn:route', $options);
|
||||
}
|
||||
|
@ -64,20 +64,13 @@ class ResourceCommand extends BaseCommand {
|
||||
if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
|
||||
$this->call('wn:controller:rest-actions');
|
||||
}
|
||||
|
||||
// generating the controller and routes
|
||||
$controllerOptions = [
|
||||
'model' => $modelName,
|
||||
'--force' => $this->option('force'),
|
||||
'--no-routes' => false,
|
||||
'--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false
|
||||
];
|
||||
try {
|
||||
if($this->option('laravel')) {
|
||||
$controllerOptions['--laravel'] = true;
|
||||
};
|
||||
} catch (InvalidArgumentException $e) {
|
||||
// Do nothing
|
||||
}
|
||||
$this->call('wn:controller', $controllerOptions);
|
||||
|
||||
// generating model factory
|
||||
|
@ -36,16 +36,9 @@ class ResourcesCommand extends BaseCommand {
|
||||
'--belongs-to-many' => $i['belongsToMany'],
|
||||
'--path' => $this->option('path'),
|
||||
'--force' => $this->option('force'),
|
||||
'--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false
|
||||
];
|
||||
|
||||
try {
|
||||
if($this->option('laravel')) {
|
||||
$options['--laravel'] = true;
|
||||
};
|
||||
} catch (InvalidArgumentException $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
$this->call('wn:resource', $options);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ class RouteCommand extends BaseCommand {
|
||||
protected $signature = 'wn:route
|
||||
{resource : Name of the resource.}
|
||||
{--controller= : Name of the RESTful controller.}
|
||||
{--laravel= : Boolean (default false) Use Laravel style route definitions
|
||||
{--laravel= : Boolean (default false) Use Laravel style route definitions}
|
||||
';
|
||||
|
||||
protected $description = 'Generates RESTful routes.';
|
||||
@ -17,15 +17,17 @@ class RouteCommand extends BaseCommand {
|
||||
{
|
||||
$resource = $this->argument('resource');
|
||||
$laravelRoutes = $this->input->hasOption('laravel') ? $this->option('laravel') : false;
|
||||
|
||||
$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
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@ -40,18 +42,17 @@ class RouteCommand extends BaseCommand {
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
Route::middleware('auth:api')->get('/user', function (Request \$request) {
|
||||
return \$request->user();
|
||||
});
|
||||
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->fs->isFile($routesPath)) {
|
||||
if (!$this->fs->isFile($routesPath)) {
|
||||
$routesPath = 'app/Http/routes.php';
|
||||
}
|
||||
|
||||
$content = $this->fs->get($routesPath);
|
||||
|
||||
$content .= PHP_EOL . $this->getTemplate($templateFile)
|
||||
|
Loading…
Reference in New Issue
Block a user