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()
57
57
->buildViews ();
58
58
59
59
$ this ->info ('Created Successfully. ' );
60
-
60
+ $ this -> generateRoutes ();
61
61
return true ;
62
62
}
63
63
@@ -160,6 +160,25 @@ protected function buildViews()
160
160
return $ this ;
161
161
}
162
162
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
+
163
182
/**
164
183
* Make the class name from table name.
165
184
*
You can’t perform that action at this time.
0 commit comments