@@ -243,7 +243,7 @@ protected function defaultBranch()
243243 protected function configureDefaultDatabaseConnection (string $ directory , string $ database , string $ name , bool $ migrate )
244244 {
245245 // MariaDB configuration only exists as of Laravel 11...
246- if ($ database === 'mariadb ' && ! $ this ->hasMariaDBConfig ($ directory )) {
246+ if ($ database === 'mariadb ' && ! $ this ->usingLaravel11OrNewer ($ directory )) {
247247 $ database = 'mysql ' ;
248248 }
249249
@@ -308,22 +308,18 @@ protected function configureDefaultDatabaseConnection(string $directory, string
308308 }
309309
310310 /**
311- * Determine if the application has a MariaDB configuration entry .
311+ * Determine if the application is using Laravel 11 or newer .
312312 *
313313 * @param string $directory
314314 * @return bool
315315 */
316- protected function hasMariaDBConfig (string $ directory ): bool
316+ public function usingLaravel11OrNewer (string $ directory ): bool
317317 {
318- // Laravel 11+ has moved the configuration files into the framework...
319- if (! file_exists ($ directory .'/config/database.php ' )) {
320- return true ;
321- }
318+ $ version = json_decode (file_get_contents ($ directory .'/composer.json ' ), true )['require ' ]['laravel/framework ' ];
319+ $ version = str_replace ('^ ' , '' , $ version );
320+ $ version = explode ('. ' , $ version )[0 ];
322321
323- return str_contains (
324- file_get_contents ($ directory .'/config/database.php ' ),
325- "'mariadb' => "
326- );
322+ return $ version >= 11 ;
327323 }
328324
329325 /**
@@ -450,7 +446,7 @@ protected function installJetstream(string $directory, InputInterface $input, Ou
450446 protected function promptForDatabaseOptions (string $ directory , InputInterface $ input )
451447 {
452448 // Laravel 11.x appliations use SQLite as default...
453- $ defaultDatabase = $ this ->hasMariaDBConfig ($ directory ) ? 'sqlite ' : 'mysql ' ;
449+ $ defaultDatabase = $ this ->usingLaravel11OrNewer ($ directory ) ? 'sqlite ' : 'mysql ' ;
454450
455451 if ($ input ->isInteractive ()) {
456452 $ database = select (
@@ -465,7 +461,7 @@ protected function promptForDatabaseOptions(string $directory, InputInterface $i
465461 default: $ defaultDatabase
466462 );
467463
468- if ($ database !== $ defaultDatabase ) {
464+ if ($ this -> usingLaravel11OrNewer ( $ directory ) && $ database !== $ defaultDatabase ) {
469465 $ migrate = confirm (label: 'Default database updated. Would you like to run the default database migrations? ' , default: true );
470466 }
471467 }
0 commit comments