File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function handle()
5757 ->buildViews ();
5858
5959 $ this ->info ('Created Successfully. ' );
60-
60+ $ this -> generateRoutes ();
6161 return true ;
6262 }
6363
@@ -160,6 +160,25 @@ protected function buildViews()
160160 return $ this ;
161161 }
162162
163+ protected function generateRoutes ()
164+ {
165+ $ route =$ this ->options ['route ' ] ?? Str::kebab (Str::plural ($ this ->name ));
166+ $ routePath = base_path ('routes/web.php ' );
167+ $ routeContent = File::get ($ routePath );
168+
169+ // Define the route string to check and add
170+ $ routeString = "Route::resource(' " . strtolower ($ route ) . "', ' " . $ this ->name . "Controller'); " ;
171+
172+ // Check if the route string already exists in web.php
173+ if (strpos ($ routeContent , $ routeString ) === false ) {
174+ // If not, append the route string to the file
175+ File::append ($ routePath , "\n" . $ routeString );
176+ $ this ->info ('Route added successfully. ' );
177+ } else {
178+ $ this ->info ('Route already exists. ' );
179+ }
180+ }
181+
163182 /**
164183 * Make the class name from table name.
165184 *
You can’t perform that action at this time.
0 commit comments