Skip to content

Commit

Permalink
Formatting the given db_name internally
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrancodes committed Mar 18, 2024
1 parent 0c8344a commit ae136d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Actions/FormattedBranchName.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FormattedBranchName

protected const SLUGIFY_DICTIONARY = ['+' => '-', '_' => '-', '@' => '-'];

public function handle(string $branch, ?string $pattern): string
public function handle(string $branch, ?string $pattern = null): string
{
if (isset($pattern)) {
preg_match($pattern, $branch, $matches);
Expand Down
11 changes: 8 additions & 3 deletions app/Services/Forge/ForgeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Actions\FormattedBranchName;
use App\Actions\GenerateDomainName;
use App\Actions\GenerateStandardizedBranchName;
use Illuminate\Support\Str;
use Laravel\Forge\Forge;
use Laravel\Forge\Resources\Server;
use Laravel\Forge\Resources\Site;
Expand Down Expand Up @@ -89,9 +90,13 @@ public function getSiteIsolationUsername(): string

public function getFormattedDatabaseName(): string
{
return $this->setting->dbName ?? GenerateStandardizedBranchName::run(
$this->getFormattedBranchName()
);
if ($this->setting->dbName) {
$dbName = FormattedBranchName::run($this->setting->dbName);
} else {
$dbName = $this->getFormattedBranchName();
}

return Str::replace('-', '_', $dbName);
}

public function siteNginxTemplate(): string
Expand Down

0 comments on commit ae136d9

Please sign in to comment.