@@ -29,10 +29,10 @@ class GeneratorConfig
2929
3030 public array $ dynamicVars = [];
3131
32- public string $ tableName ;
32+ public $ tableName ;
3333 public string $ tableType ;
34- public string $ primaryName ;
35- public string $ connection ;
34+ public $ primaryName ;
35+ public $ connection ;
3636
3737 public function init ()
3838 {
@@ -41,11 +41,9 @@ public function init()
4141 $ this ->loadPaths ();
4242 $ this ->tableType = config ('laravel_generator.tables ' , 'blade ' );
4343 $ this ->loadNamespaces ();
44- $ this ->prepareTableName ();
45- $ this ->preparePrimaryName ();
44+ $ this ->prepareTable ();
4645 $ this ->prepareAddons ();
4746 $ this ->prepareOptions ();
48- $ this ->loadDynamicVariables ();
4947 }
5048
5149 public function setCommand (Command &$ command )
@@ -231,107 +229,23 @@ public function loadNamespaces()
231229 $ this ->namespaces = $ namespaces ;
232230 }
233231
234- public function loadDynamicVariables ()
235- {
236- $ this ->addDynamicVariable ('$NAMESPACE_APP$ ' , $ this ->namespaces ->app );
237- $ this ->addDynamicVariable ('$NAMESPACE_REPOSITORY$ ' , $ this ->namespaces ->repository );
238- $ this ->addDynamicVariable ('$NAMESPACE_MODEL$ ' , $ this ->namespaces ->model );
239- $ this ->addDynamicVariable ('$NAMESPACE_DATATABLES$ ' , $ this ->namespaces ->dataTables );
240- $ this ->addDynamicVariable ('$NAMESPACE_LIVEWIRE_TABLES$ ' , $ this ->namespaces ->livewireTables );
241- $ this ->addDynamicVariable ('$NAMESPACE_MODEL_EXTEND$ ' , $ this ->namespaces ->modelExtend );
242-
243- $ this ->addDynamicVariable ('$NAMESPACE_SEEDER$ ' , $ this ->namespaces ->seeder );
244- $ this ->addDynamicVariable ('$NAMESPACE_FACTORY$ ' , $ this ->namespaces ->factory );
245-
246- $ this ->addDynamicVariable ('$NAMESPACE_API_CONTROLLER$ ' , $ this ->namespaces ->apiController );
247- $ this ->addDynamicVariable ('$NAMESPACE_API_RESOURCE$ ' , $ this ->namespaces ->apiResource );
248- $ this ->addDynamicVariable ('$NAMESPACE_API_REQUEST$ ' , $ this ->namespaces ->apiRequest );
249-
250- $ this ->addDynamicVariable ('$NAMESPACE_BASE_CONTROLLER$ ' , $ this ->namespaces ->baseController );
251- $ this ->addDynamicVariable ('$NAMESPACE_CONTROLLER$ ' , $ this ->namespaces ->controller );
252- $ this ->addDynamicVariable ('$NAMESPACE_REQUEST$ ' , $ this ->namespaces ->request );
253- $ this ->addDynamicVariable ('$NAMESPACE_REQUEST_BASE$ ' , $ this ->namespaces ->requestBase );
254-
255- $ this ->addDynamicVariable ('$NAMESPACE_API_TESTS$ ' , $ this ->namespaces ->apiTests );
256- $ this ->addDynamicVariable ('$NAMESPACE_REPOSITORIES_TESTS$ ' , $ this ->namespaces ->repositoryTests );
257- $ this ->addDynamicVariable ('$NAMESPACE_TESTS$ ' , $ this ->namespaces ->tests );
258-
259- $ this ->addDynamicVariable ('$TABLE_NAME$ ' , $ this ->tableName );
260- $ this ->addDynamicVariable ('$TABLE_NAME_TITLE$ ' , Str::studly ($ this ->tableName ));
261- $ this ->addDynamicVariable ('$PRIMARY_KEY_NAME$ ' , $ this ->primaryName );
262-
263- $ this ->addDynamicVariable ('$MODEL_NAME$ ' , $ this ->modelNames ->name );
264- $ this ->addDynamicVariable ('$MODEL_NAME_CAMEL$ ' , $ this ->modelNames ->camel );
265- $ this ->addDynamicVariable ('$MODEL_NAME_PLURAL$ ' , $ this ->modelNames ->plural );
266- $ this ->addDynamicVariable ('$MODEL_NAME_PLURAL_CAMEL$ ' , $ this ->modelNames ->camelPlural );
267- $ this ->addDynamicVariable ('$MODEL_NAME_SNAKE$ ' , $ this ->modelNames ->snake );
268- $ this ->addDynamicVariable ('$MODEL_NAME_PLURAL_SNAKE$ ' , $ this ->modelNames ->snakePlural );
269- $ this ->addDynamicVariable ('$MODEL_NAME_DASHED$ ' , $ this ->modelNames ->dashed );
270- $ this ->addDynamicVariable ('$MODEL_NAME_PLURAL_DASHED$ ' , $ this ->modelNames ->dashedPlural );
271- $ this ->addDynamicVariable ('$MODEL_NAME_HUMAN$ ' , $ this ->modelNames ->human );
272- $ this ->addDynamicVariable ('$MODEL_NAME_PLURAL_HUMAN$ ' , $ this ->modelNames ->humanPlural );
273- $ this ->addDynamicVariable ('$FILES$ ' , '' );
274-
275- $ connectionText = '' ;
276- if ($ connection = $ this ->getOption ('connection ' )) {
277- $ this ->connection = $ connection ;
278- $ connectionText = infy_tabs (4 ).'public $connection = " ' .$ connection .'"; ' ;
279- }
280- $ this ->addDynamicVariable ('$CONNECTION$ ' , $ connectionText );
281-
282- $ this ->addDynamicVariable ('$PRIMARY_KEY_NAME$ ' , $ this ->primaryName );
283-
284- if (!empty ($ this ->prefixes ->route )) {
285- $ this ->addDynamicVariable ('$ROUTE_NAMED_PREFIX$ ' , $ this ->prefixes ->route .'. ' );
286- $ this ->addDynamicVariable ('$ROUTE_PREFIX$ ' , str_replace ('. ' , '/ ' , $ this ->prefixes ->route ).'/ ' );
287- $ this ->addDynamicVariable ('$RAW_ROUTE_PREFIX$ ' , $ this ->prefixes ->route );
288- } else {
289- $ this ->addDynamicVariable ('$ROUTE_PREFIX$ ' , '' );
290- $ this ->addDynamicVariable ('$ROUTE_NAMED_PREFIX$ ' , '' );
291- }
292-
293- if (!empty ($ this ->prefixes ->namespace )) {
294- $ this ->addDynamicVariable ('$PATH_PREFIX$ ' , $ this ->prefixes ->namespace .'\\' );
295- } else {
296- $ this ->addDynamicVariable ('$PATH_PREFIX$ ' , '' );
297- }
298-
299- if (!empty ($ this ->prefixes ->view )) {
300- $ this ->addDynamicVariable ('$VIEW_PREFIX$ ' , str_replace ('/ ' , '. ' , $ this ->prefixes ->view ).'. ' );
301- } else {
302- $ this ->addDynamicVariable ('$VIEW_PREFIX$ ' , '' );
303- }
304-
305- if (!empty ($ this ->prefixes ->public )) {
306- $ this ->addDynamicVariable ('$PUBLIC_PREFIX$ ' , $ this ->prefixes ->public );
307- } else {
308- $ this ->addDynamicVariable ('$PUBLIC_PREFIX$ ' , '' );
309- }
310-
311- $ this ->addDynamicVariable (
312- '$API_PREFIX$ ' ,
313- config ('laravel_generator.api_prefix ' , 'api ' )
314- );
315-
316- $ this ->addDynamicVariable ('$SEARCHABLE$ ' , '' );
317- }
318-
319- public function prepareTableName ()
232+ public function prepareTable ()
320233 {
321234 if ($ this ->getOption ('table ' )) {
322235 $ this ->tableName = $ this ->getOption ('table ' );
323236 } else {
324237 $ this ->tableName = $ this ->modelNames ->snakePlural ;
325238 }
326- }
327239
328- public function preparePrimaryName ()
329- {
330240 if ($ this ->getOption ('primary ' )) {
331241 $ this ->primaryName = $ this ->getOption ('primary ' );
332242 } else {
333243 $ this ->primaryName = 'id ' ;
334244 }
245+
246+ if ($ this ->getOption ('connection ' )) {
247+ $ this ->connection = $ this ->getOption ('connection ' );
248+ }
335249 }
336250
337251 public function prepareOptions ()
0 commit comments