Skip to content

Commit f27d366

Browse files
authored
Remove Laravel 11 Checks (#319)
1 parent bead235 commit f27d366

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/NewCommand.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ protected function defaultBranch()
249249
*/
250250
protected function configureDefaultDatabaseConnection(string $directory, string $database, string $name, bool $migrate)
251251
{
252-
// MariaDB configuration only exists as of Laravel 11...
253-
if ($database === 'mariadb' && ! $this->usingLaravel11OrNewer($directory)) {
254-
$database = 'mysql';
255-
}
256-
257252
$this->pregReplaceInFile(
258253
'/DB_CONNECTION=.*/',
259254
'DB_CONNECTION='.$database,
@@ -320,13 +315,13 @@ protected function configureDefaultDatabaseConnection(string $directory, string
320315
* @param string $directory
321316
* @return bool
322317
*/
323-
public function usingLaravel11OrNewer(string $directory): bool
318+
public function usingLaravelVersionOrNewer(int $usingVersion, string $directory): bool
324319
{
325320
$version = json_decode(file_get_contents($directory.'/composer.json'), true)['require']['laravel/framework'];
326321
$version = str_replace('^', '', $version);
327322
$version = explode('.', $version)[0];
328323

329-
return $version >= 11;
324+
return $version >= $usingVersion;
330325
}
331326

332327
/**
@@ -452,8 +447,7 @@ protected function installJetstream(string $directory, InputInterface $input, Ou
452447
*/
453448
protected function promptForDatabaseOptions(string $directory, InputInterface $input)
454449
{
455-
// Laravel 11.x appliations use SQLite as default...
456-
$defaultDatabase = $this->usingLaravel11OrNewer($directory) ? 'sqlite' : 'mysql';
450+
$defaultDatabase = 'sqlite';
457451

458452
if ($input->isInteractive()) {
459453
$database = select(
@@ -468,7 +462,7 @@ protected function promptForDatabaseOptions(string $directory, InputInterface $i
468462
default: $defaultDatabase
469463
);
470464

471-
if ($this->usingLaravel11OrNewer($directory) && $database !== $defaultDatabase) {
465+
if ($database !== $defaultDatabase) {
472466
$migrate = confirm(label: 'Default database updated. Would you like to run the default database migrations?', default: true);
473467
}
474468
}

tests/NewCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function test_on_at_least_laravel_11()
3838
{
3939
$command = new NewCommand;
4040

41-
$onLaravel10 = $command->usingLaravel11OrNewer(__DIR__.'/fixtures/laravel10');
42-
$onLaravel11 = $command->usingLaravel11OrNewer(__DIR__.'/fixtures/laravel11');
43-
$onLaravel12 = $command->usingLaravel11OrNewer(__DIR__.'/fixtures/laravel12');
41+
$onLaravel10 = $command->usingLaravelVersionOrNewer(11, __DIR__.'/fixtures/laravel10');
42+
$onLaravel11 = $command->usingLaravelVersionOrNewer(11, __DIR__.'/fixtures/laravel11');
43+
$onLaravel12 = $command->usingLaravelVersionOrNewer(11, __DIR__.'/fixtures/laravel12');
4444

4545
$this->assertFalse($onLaravel10);
4646
$this->assertTrue($onLaravel11);

0 commit comments

Comments
 (0)