diff --git a/src/Common/GeneratorConfig.php b/src/Common/GeneratorConfig.php index c96f53300..9fea80fcf 100755 --- a/src/Common/GeneratorConfig.php +++ b/src/Common/GeneratorConfig.php @@ -47,6 +47,8 @@ class GeneratorConfig public $mSnakePlural; public $mDashed; public $mDashedPlural; + public $mHuman; + public $mHumanPlural; public $forceMigrate; @@ -176,7 +178,7 @@ public function loadPaths() $this->pathViews = config( 'infyom.laravel_generator.path.views', base_path('resources/views/') - ).$viewPrefix.$this->mCamelPlural.'/'; + ).$viewPrefix.$this->mSnakePlural.'/'; $this->modelJsPath = config( 'infyom.laravel_generator.path.modelsJs', @@ -210,6 +212,8 @@ public function loadDynamicVariables(CommandData &$commandData) $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_SNAKE$', $this->mSnakePlural); $commandData->addDynamicVariable('$MODEL_NAME_DASHED$', $this->mDashed); $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_DASHED$', $this->mDashedPlural); + $commandData->addDynamicVariable('$MODEL_NAME_HUMAN$', $this->mHuman); + $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_HUMAN$', $this->mHumanPlural); if (!empty($this->prefixes['route'])) { $commandData->addDynamicVariable('$ROUTE_NAMED_PREFIX$', $this->prefixes['route'].'.'); @@ -266,6 +270,10 @@ public function prepareModelNames() $this->mCamelPlural = Str::camel($this->mPlural); $this->mSnake = Str::snake($this->mName); $this->mSnakePlural = Str::snake($this->mPlural); + $this->mDashed = str_replace("_", "-", Str::snake($this->mSnake)); + $this->mDashedPlural = str_replace("_", "-", Str::snake($this->mSnakePlural)); + $this->mHuman = title_case(str_replace("_", " ", Str::snake($this->mSnake))); + $this->mHumanPlural = title_case(str_replace("_", " ", Str::snake($this->mSnakePlural))); } public function prepareOptions(CommandData &$commandData) diff --git a/templates/api/controller/api_controller.stub b/templates/api/controller/api_controller.stub index ee295081b..139a8aa17 100755 --- a/templates/api/controller/api_controller.stub +++ b/templates/api/controller/api_controller.stub @@ -30,7 +30,7 @@ class $MODEL_NAME$APIController extends AppBaseController $this->$MODEL_NAME_CAMEL$Repository->pushCriteria(new LimitOffsetCriteria($request)); $$MODEL_NAME_PLURAL_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->all(); - return $this->sendResponse($$MODEL_NAME_PLURAL_CAMEL$->toArray(), '$MODEL_NAME_PLURAL$ retrieved successfully'); + return $this->sendResponse($$MODEL_NAME_PLURAL_CAMEL$->toArray(), '$MODEL_NAME_PLURAL_HUMAN$ retrieved successfully'); } $DOC_STORE$ @@ -40,7 +40,7 @@ class $MODEL_NAME$APIController extends AppBaseController $$MODEL_NAME_PLURAL_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->create($input); - return $this->sendResponse($$MODEL_NAME_PLURAL_CAMEL$->toArray(), '$MODEL_NAME$ saved successfully'); + return $this->sendResponse($$MODEL_NAME_PLURAL_CAMEL$->toArray(), '$MODEL_NAME_HUMAN$ saved successfully'); } $DOC_SHOW$ @@ -50,10 +50,10 @@ class $MODEL_NAME$APIController extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->find($id); if (empty($$MODEL_NAME_CAMEL$)) { - return $this->sendError('$MODEL_NAME$ not found'); + return $this->sendError('$MODEL_NAME_HUMAN$ not found'); } - return $this->sendResponse($$MODEL_NAME_CAMEL$->toArray(), '$MODEL_NAME$ retrieved successfully'); + return $this->sendResponse($$MODEL_NAME_CAMEL$->toArray(), '$MODEL_NAM_HUMANE$ retrieved successfully'); } $DOC_UPDATE$ @@ -65,7 +65,7 @@ class $MODEL_NAME$APIController extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->find($id); if (empty($$MODEL_NAME_CAMEL$)) { - return $this->sendError('$MODEL_NAME$ not found'); + return $this->sendError('$MODEL_NAME_HUMAN$ not found'); } $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->update($input, $id); @@ -80,11 +80,11 @@ class $MODEL_NAME$APIController extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->find($id); if (empty($$MODEL_NAME_CAMEL$)) { - return $this->sendError('$MODEL_NAME$ not found'); + return $this->sendError('$MODEL_NAME_HUMAN$ not found'); } $$MODEL_NAME_CAMEL$->delete(); - return $this->sendResponse($id, '$MODEL_NAME$ deleted successfully'); + return $this->sendResponse($id, '$MODEL_NAME_HUMAN$ deleted successfully'); } } diff --git a/templates/scaffold/controller/controller.stub b/templates/scaffold/controller/controller.stub index 22d2391c1..2c446a4fd 100755 --- a/templates/scaffold/controller/controller.stub +++ b/templates/scaffold/controller/controller.stub @@ -32,7 +32,7 @@ class $MODEL_NAME$Controller extends AppBaseController $this->$MODEL_NAME_CAMEL$Repository->pushCriteria(new RequestCriteria($request)); $$MODEL_NAME_PLURAL_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->$RENDER_TYPE$; - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index') + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.index') ->with('$MODEL_NAME_PLURAL_CAMEL$', $$MODEL_NAME_PLURAL_CAMEL$); } @@ -43,7 +43,7 @@ class $MODEL_NAME$Controller extends AppBaseController */ public function create() { - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.create'); + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.create'); } /** @@ -59,7 +59,7 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->create($input); - Flash::success('$MODEL_NAME$ saved successfully.'); + Flash::success('$MODEL_NAME_HUMAN$ saved successfully.'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } @@ -76,12 +76,12 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.show')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.show')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); } /** @@ -96,12 +96,12 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.edit')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.edit')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); } /** @@ -117,14 +117,14 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->update($request->all(), $id); - Flash::success('$MODEL_NAME$ updated successfully.'); + Flash::success('$MODEL_NAME_HUMAN$ updated successfully.'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } @@ -141,14 +141,14 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } $this->$MODEL_NAME_CAMEL$Repository->delete($id); - Flash::success('$MODEL_NAME$ deleted successfully.'); + Flash::success('$MODEL_NAME_HUMAN$ deleted successfully.'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } diff --git a/templates/scaffold/controller/datatable_controller.stub b/templates/scaffold/controller/datatable_controller.stub index 7a8e13ead..5dad167e2 100755 --- a/templates/scaffold/controller/datatable_controller.stub +++ b/templates/scaffold/controller/datatable_controller.stub @@ -29,7 +29,7 @@ class $MODEL_NAME$Controller extends AppBaseController */ public function index($MODEL_NAME$DataTable $$MODEL_NAME_CAMEL$DataTable) { - return $$MODEL_NAME_CAMEL$DataTable->render('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index'); + return $$MODEL_NAME_CAMEL$DataTable->render('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.index'); } /** @@ -39,7 +39,7 @@ class $MODEL_NAME$Controller extends AppBaseController */ public function create() { - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.create'); + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.create'); } /** @@ -55,7 +55,7 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->create($input); - Flash::success('$MODEL_NAME$ saved successfully.'); + Flash::success('$MODEL_NAME_HUMAN$ saved successfully.'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } @@ -72,12 +72,12 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.show')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.show')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); } /** @@ -92,12 +92,12 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } - return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.edit')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); + return view('$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.edit')->with('$MODEL_NAME_CAMEL$', $$MODEL_NAME_CAMEL$); } /** @@ -113,14 +113,14 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->update($request->all(), $id); - Flash::success('$MODEL_NAME$ updated successfully.'); + Flash::success('$MODEL_NAME_HUMAN$ updated successfully.'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } @@ -137,14 +137,14 @@ class $MODEL_NAME$Controller extends AppBaseController $$MODEL_NAME_CAMEL$ = $this->$MODEL_NAME_CAMEL$Repository->findWithoutFail($id); if (empty($$MODEL_NAME_CAMEL$)) { - Flash::error('$MODEL_NAME$ not found'); + Flash::error('$MODEL_NAME_HUMAN$ not found'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } $this->$MODEL_NAME_CAMEL$Repository->delete($id); - Flash::success('$MODEL_NAME$ deleted successfully.'); + Flash::success('$MODEL_NAME_HUMAN$ deleted successfully.'); return redirect(route('$ROUTE_NAMED_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.index')); } diff --git a/templates/scaffold/datatable.stub b/templates/scaffold/datatable.stub index 71805ae51..4794ecc19 100755 --- a/templates/scaffold/datatable.stub +++ b/templates/scaffold/datatable.stub @@ -16,7 +16,7 @@ class $MODEL_NAME$DataTable extends DataTable { return $this->datatables ->eloquent($this->query()) - ->addColumn('action', '$VIEW_PREFIX$$MODEL_NAME_PLURAL_CAMEL$.datatables_actions') + ->addColumn('action', '$VIEW_PREFIX$$MODEL_NAME_PLURAL_SNAKE$.datatables_actions') ->make(true); } @@ -47,7 +47,6 @@ class $MODEL_NAME$DataTable extends DataTable 'dom' => 'Bfrtip', 'scrollX' => false, 'buttons' => [ - 'create', 'print', 'reset', 'reload',