Skip to content

Commit b6edb0a

Browse files
feat:lar-102 remove down function in avatat migration , add navigate true in url ...etc
1 parent a9eb114 commit b6edb0a

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

app/Livewire/Components/User/Activities.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ final class Activities extends Component
1313
{
1414
public User $user;
1515

16-
public function mount(User $user): void
17-
{
18-
$this->user = $user;
19-
}
20-
2116
public function render(): View
2217
{
2318
return view('livewire.components.user.activities', [

app/Livewire/Components/User/Preferences.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function updatedTheme(string $value): void
3232
{
3333
$this->user->settings(['theme' => $value]);
3434

35-
$this->redirectRoute('settings');
35+
$this->redirectRoute('settings', navigate: true);
3636
}
3737

3838
public function render(): View

app/Livewire/Pages/Account/Profile.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ final class Profile extends Component
1414

1515
public function mount(User $user): void
1616
{
17-
$this->user = $user;
18-
$this->user = $this->user->load([
17+
$this->user = $user->load([
1918
'activities',
2019
'articles',
2120
'articles.tags',

app/Traits/FormatSocialAccount.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ trait FormatSocialAccount
88
{
99
public function formatTwitterHandle(?string $userSocial): ?string
1010
{
11-
1211
if (! $userSocial) {
1312
return null;
1413
}
@@ -22,6 +21,7 @@ public function formatTwitterHandle(?string $userSocial): ?string
2221
if (str_contains($handle, 'https://twitter.com/')) {
2322
return substr($handle, strlen('https://twitter.com/'));
2423
}
24+
2525
if (str_contains($handle, '@')) {
2626
return substr($handle, strlen('@'));
2727
}
@@ -31,7 +31,6 @@ public function formatTwitterHandle(?string $userSocial): ?string
3131

3232
public function formatGithubHandle(?string $userSocial): ?string
3333
{
34-
3534
if (! $userSocial) {
3635
return null;
3736
}

database/migrations/2024_12_14_210022_remove_avatar_from_users_table.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,4 @@ public function up(): void
1414
$table->dropColumn('avatar');
1515
});
1616
}
17-
18-
public function down(): void
19-
{
20-
Schema::table('users', function (Blueprint $table): void {
21-
$table->string('avatar')->nullable();
22-
});
23-
}
2417
};

tests/Feature/Command/UpdateUserSocialAccountTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,36 @@
33
declare(strict_types=1);
44

55
use App\Console\Commands\UpdateUserSocialAccount;
6+
use App\Models\User;
67

78
beforeEach(function (): void {
8-
$this->user = $this->login(['email' => '[email protected]',
9+
$this->user = $this->login([
10+
'email' => '[email protected]',
911
'twitter_profile' => 'https://x.com/LaravelCm',
1012
'github_profile' => 'https://github.com/laravelcm',
11-
'linkedin_profile' => 'https://www.linkedin.com/in/laravel-cm/']);
13+
'linkedin_profile' => 'https://www.linkedin.com/in/laravel-cm/',
14+
]);
15+
16+
$this->second_user = User::factory()->create([
17+
'twitter_profile' => '@shopperLabs',
18+
]);
1219
});
1320

1421
describe(UpdateUserSocialAccount::class, function (): void {
1522
it('can update all user profile with command', function (): void {
1623
$this->artisan('lcm:update-user-social-account')->assertSuccessful();
1724

1825
$this->user->refresh();
26+
$this->second_user->refresh();
1927

2028
expect($this->user->twitter_profile)
2129
->toBe('LaravelCm')
2230
->and($this->user->github_profile)
2331
->toBe('laravelcm')
2432
->and($this->user->linkedin_profile)
2533
->toBe('laravel-cm/');
34+
35+
expect($this->second_user->twitter_profile)
36+
->toBe('shopperLabs');
2637
});
2738
});

tests/Feature/Livewire/Components/User/ActivitiesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
use Livewire\Livewire;
77

88
it('renders successfully', function (): void {
9-
Livewire::test(Activities::class)
9+
Livewire::test(Activities::class, ['user' => $this->login()])
1010
->assertStatus(200);
1111
});

0 commit comments

Comments
 (0)