Skip to content

Commit 173bc19

Browse files
update migration file and add phpstan ignore line
1 parent 4b928e5 commit 173bc19

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

app/Http/Middleware/LocaleMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function handle(Request $request, Closure $next): Response
2626
if (! Auth::check()) {
2727

2828
if (! is_null($request->server('HTTP_ACCEPT_LANGUAGE'))) {
29-
$navigatorLang = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
29+
$navigatorLang = substr((string) $request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2); // @phpstan-ignore-line
3030

3131
if (in_array($navigatorLang, $supportLang)) {
3232
$lang = $navigatorLang;

database/migrations/2024_12_03_004238_add_locale_column_to_tables.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
return new class extends Migration
1010
{
11+
private array $tables = ['articles', 'discussions', 'threads'];
12+
1113
public function up(): void
1214
{
13-
foreach (['articles', 'discussions', 'threads'] as $key => $value) {
14-
$afterColumn = ($key == 0) ? 'slug' : 'body';
15-
Schema::table($value, function (Blueprint $table) use ($afterColumn): void {
16-
$table->string('locale')->default('fr')->after($afterColumn);
15+
foreach ($this->tables as $tab) {
16+
Schema::table($tab, function (Blueprint $table): void {
17+
$table->string('locale')->default('fr');
1718
});
1819
}
1920
}
2021

2122
public function down(): void
2223
{
23-
foreach (['articles', 'discussions', 'threads'] as $tab) {
24+
foreach ($this->tables as $tab) {
2425
Schema::table($tab, function (Blueprint $table): void {
2526
$table->dropColumn('locale');
2627
});

resources/views/components/layouts/footer.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class="ml-2 size-6 rounded-full"
9999
<x-icon.youtube class="size-6" aria-hidden="true" />
100100
</x-link>
101101
</div>
102-
<livewire:components.change-locale></livewire:components.change-locale>
102+
<livewire:components.change-locale />
103103
</div>
104104
</x-container>
105105
</div>

0 commit comments

Comments
 (0)