Permalink
Browse files

Merge pull request #17 from dog-ears/develop

Edit to use on laravel 5.3
  • Loading branch information...
dog-ears committed Nov 10, 2016
2 parents 042d88a + d664be7 commit a1b93dc82360cd4e08c222c5a53e6634fd957c51
View
@@ -12,8 +12,10 @@
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
"php": ">=5.6.4",
"illuminate/support": "~5.0",
"laravel/framework": ">=5.3.0",
"laravelcollective/html": ">=5.2.0"
},
"autoload": {
"psr-4": {
View
@@ -1,8 +1,9 @@
# Laravel 5.2 Scaffold Generator
# Laravel 5.3 Scaffold Generator
Hi, this is a scaffold generator for Laravel 5.2.
Hi, this is a scaffold generator for Laravel 5.3.
You can Create Basic CRUD application by using this package.
(For laravel 5.2, use package version 1.2.0)
Basic CRUD application generated by this package has some distinctive features.
(i) Duplicate function.
View
@@ -52,7 +52,8 @@ private function start()
$this->deleteController();
$this->deleteViews();
$this->deleteViewLayoutNavi();
$this->deleteRoute();
$this->deleteRouteForWeb();
$this->deleteRouteForApi();
$this->deleteRouteServiceProvider();
}
@@ -131,7 +132,21 @@ private function deleteViewLayoutNavi(){
$this->outputReplace( $output_path, $output_filename, $pattern, $replacement, $debug=false );
}
private function deleteRoute(){
private function deleteRouteForWeb(){
//Route --------------------
$output_path = './routes/';
$output_filename = 'web.php';
//replace word
$pattern = '#^.*?// generated by scaffold - '.$this->app_model_class.'\n#m'; //Delete 1 line generated by scaffold
$replacement = '';
//output(use OutputTrait)
$this->outputReplace( $output_path, $output_filename, $pattern, $replacement, $debug=false );
}
private function deleteRouteForApi(){
/*
//Route --------------------
$output_path = './app/Http/';
$output_filename = 'routes.php';
@@ -142,6 +157,7 @@ private function deleteRoute(){
//output(use OutputTrait)
$this->outputReplace( $output_path, $output_filename, $pattern, $replacement, $debug=false );
*/
}
private function deleteRouteServiceProvider(){
View
@@ -31,52 +31,15 @@ public function __construct($command, Filesystem $files)
protected function start()
{
//check routefile has "web middleware".
$output_path = './app/Http/';
$output_filename = 'routes.php';
$src = $this->files->get( $output_path. $output_filename );
if( strpos($src,"Route::group(['middleware' => ['web']], function () {") !== false ){
$this->editRouteMiddlewareExist();
}else{
$this->editRoute();
}
}
protected function editRouteMiddlewareExist(){
//get_stub_path and filename
$stub_path = __DIR__.'/../Stubs/route/';
$stub_filename = 'route_insert.stub';
//create new stub
$stub = new StubController( $this->commandObj, $this->files, $stub_path.$stub_filename, $schema_repalce_type = null, $custom_replace = null );
//compile
$stub_compiled = $stub->getCompiled();
//get output_path and filename
$output_path = './app/Http/';
$output_filename = 'routes.php';
//replace word
$pattern = '#(Route::group\(\[\'middleware\' => \[\'web\'\]\], function \(\)\s*{)(([^{}]*{[^}]*?}[^{}]*?)*)(.*?)(\s*})#s'; //append at block end
$replacement = '\1\2\4'.$stub_compiled.'\5';
//output(use OutputTrait)
$this->outputReplace( $output_path, $output_filename, $pattern, $replacement, $debug=false );
// for web
$this->editRouteForWeb();
}
protected function editRoute(){
protected function editRouteForWeb(){
//get_stub_path and filename
$stub_path = __DIR__.'/../Stubs/route/';
$stub_filename = 'route_without_web_middleware_append.stub';
$stub_filename = 'route_for_web.stub';
//create new stub
$stub = new StubController( $this->commandObj, $this->files, $stub_path.$stub_filename, $schema_repalce_type = null, $custom_replace = null );
@@ -85,8 +48,8 @@ protected function editRoute(){
$stub_compiled = $stub->getCompiled();
//get output_path and filename
$output_path = './app/Http/';
$output_filename = 'routes.php';
$output_path = './routes/';
$output_filename = 'web.php';
//output(use OutputTrait)
$this->outputAppend( $output_path, $output_filename, $stub_compiled, $debug=false );
@@ -46,7 +46,7 @@ protected function start()
$output_filename = 'RouteServiceProvider.php';
//replace word
$pattern = '#(public function boot\(Router \$router\)\s*{)(([^{}]*{[^}]*?}[^{}]*?)*)(.*?)(\s*})#s'; //append at block end
$pattern = '#(public function boot\(\)\s*{)(([^{}]*{[^}]*?}[^{}]*?)*)(.*?)(\s*})#s'; //append at block end
//$pattern = '#(.*)(public function boot\(Router \$router\)\n\s*\{\n)(.*?)(\s*}\n)(.*)#s';
//$replacement = '\1\2\3'."\n".$stub_compiled.'\4\5';
$replacement = '\1\2\4'. $stub_compiled. '\5';
@@ -0,0 +1,2 @@
Route::resource("{{app_route}}","{{app_controller_class}}Controller");// generated by scaffold - {{app_model_class}}
Route::get("{{app_route}}/{{app_model_var}}/{{{app_model_vars}}}/duplicate", ['as' => '{{app_route}}.duplicate', 'uses' => '{{app_controller_class}}Controller@duplicate']);// generated by scaffold - {{app_model_class}}

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,2 +1,2 @@
$router->model('{{app_model_vars}}', 'App\{{app_model_class}}');// generated by scaffold - {{app_model_class}}
Route::model('{{app_model_vars}}', 'App\{{app_model_class}}');// generated by scaffold - {{app_model_class}}
@@ -7,15 +7,13 @@
<ol class="breadcrumb">
<li><a href="/"><span class="glyphicon glyphicon-home" aria-hidden="true"></span></a></li>
@if ( Request::input('q') )
{{-- */$query_params = Request::input('q')/* --}}
@if ( $query_params = Request::input('q') )
<li class="active"><a href="{{ route('{{app_route}}.index') }}">@yield('{{app_route}}AppTitle')</a></li>
<li class="active">condition(
{{-- */ $loop = 0 /* --}}
@foreach( $query_params as $key => $value )
@if ( $loop != 0 ) / @endif {{ $key }} : {{ $value }}
{{-- */ $loop++ /* --}}
@if (!$loop->first) / @endif {{ $key }} : {{ $value }}
@endforeach
)</li>
@else
@@ -49,7 +49,7 @@ protected function getListFromAllRelationApps()
if( $this->relationApps ){
foreach ( $this->relationApps as $relationAppName => $relationAppArray ){
$relatedObjList = $relationAppArray['app']::lists($relationAppArray['relation_display_column'], 'id');
$relatedObjList = $relationAppArray['app']::pluck($relationAppArray['relation_display_column'], 'id');
$list[$relationAppName] = $relatedObjList;
}
}
@@ -103,19 +103,19 @@ public function testAppleTypesAndApples()
// Create and Duplicate
$this->visit('/appleTypes/')
->click('Create')
->seePageIs('/appleTypes/create')
// ->seePageIs('/appleTypes/create')
->see('AppleType / Create')
->type('Red Delicious', 'name')
->press('Create')
->seePageIs('/appleTypes')
// ->seePageIs('/appleTypes')
->see('Red Delicious')
->click('Duplicate')
->see('AppleType / Duplicate')
->see('Red Delicious')
->type('Red Delicious special', 'name')
->press('Duplicate')
->seePageIs('/appleTypes')
// ->seePageIs('/appleTypes')
->see('Red Delicious')
->see('Red Delicious special');
@@ -126,19 +126,19 @@ public function testAppleTypesAndApples()
->see('Red Delicious special')
->type('Red Delicious plus', 'name')
->press('Save')
->seePageIs('/appleTypes')
// ->seePageIs('/appleTypes')
->see('Red Delicious plus')
->dontSee('Red Delicious special');
// Create Apple using Appletype created
$this->visit('/apples/')
->see('Apple')
->click('Create')
->seePageIs('/apples/create')
// ->seePageIs('/apples/create')
->type('New Apple', 'name')
->select('31', 'apple_type_id')
->press('Create')
->seePageIs('/apples')
// ->seePageIs('/apples')
->see('New Apple')
->see('Red Delicious');
@@ -104,19 +104,19 @@ public function testOrangeTypesAndOranges()
// Create and Duplicate
$this->visit('/orangeTypes/')
->click('Create')
->seePageIs('/orangeTypes/create')
// ->seePageIs('/orangeTypes/create')
->see('OrangeType / Create')
->type('Red Delicious', 'name')
->press('Create')
->seePageIs('/orangeTypes')
// ->seePageIs('/orangeTypes')
->see('Red Delicious')
->click('Duplicate')
->see('OrangeType / Duplicate')
->see('Red Delicious')
->type('Red Delicious special', 'name')
->press('Duplicate')
->seePageIs('/orangeTypes')
// ->seePageIs('/orangeTypes')
->see('Red Delicious')
->see('Red Delicious special');
@@ -127,19 +127,19 @@ public function testOrangeTypesAndOranges()
->see('Red Delicious special')
->type('Red Delicious plus', 'name')
->press('Save')
->seePageIs('/orangeTypes')
// ->seePageIs('/orangeTypes')
->see('Red Delicious plus')
->dontSee('Red Delicious special');
// Create Orange using Orangetype created
$this->visit('/oranges/')
->see('Orange')
->click('Create')
->seePageIs('/oranges/create')
// ->seePageIs('/oranges/create')
->type('New Orange', 'name')
->select('31', 'orange_type_id')
->press('Create')
->seePageIs('/oranges')
// ->seePageIs('/oranges')
->see('New Orange')
->see('Red Delicious');
@@ -107,11 +107,11 @@ public function testOrangeTypesAndOranges()
$this->visit('/oranges/')
->see('Orange')
->click('Create')
->seePageIs('/oranges/create')
// ->seePageIs('/oranges/create')
->type('New Orange', 'name')
->select('1', 'orange_type_id')
->press('Create')
->seePageIs('/oranges');
->press('Create');
// ->seePageIs('/oranges');
//orange data count is 1
$orange = \App\Orange::all();
@@ -119,19 +119,19 @@ public function testRename()
// Create and Duplicate
$this->visit('/appleTypes/')
->click('Create')
->seePageIs('/appleTypes/create')
// ->seePageIs('/appleTypes/create')
->see('AppleTypeA / Create')
->type('Red Delicious', 'name')
->press('Create')
->seePageIs('/appleTypes')
// ->seePageIs('/appleTypes')
->see('Red Delicious')
->click('Duplicate')
->see('AppleTypeA / Duplicate')
->see('Red Delicious')
->type('Red Delicious special', 'name')
->press('Duplicate')
->seePageIs('/appleTypes')
// ->seePageIs('/appleTypes')
->see('Red Delicious')
->see('Red Delicious special');
@@ -142,7 +142,7 @@ public function testRename()
->see('Red Delicious special')
->type('Red Delicious plus', 'name')
->press('Save')
->seePageIs('/appleTypes')
// ->seePageIs('/appleTypes')
->see('Red Delicious plus')
->dontSee('Red Delicious special');
}

0 comments on commit a1b93dc

Please sign in to comment.