Skip to content

Commit c11d9fb

Browse files
committed
Apply suggested changes: rename method, fix route, and update comment
1 parent cd9abe6 commit c11d9fb

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

app/Http/Controllers/ProfileController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function show(Request $request, ?User $user = null)
2626

2727
public function refresh(Request $request)
2828
{
29-
3029
$user = $request->user();
3130

3231
if (! $user->hasConnectedGitHubAccount()) {
@@ -40,7 +39,7 @@ public function refresh(Request $request)
4039
return back()->with('error', 'Please wait 1 minute(s) before refreshing your avatar again.');
4140
}
4241

43-
// Record this attempt for 1 minutes
42+
// Record this attempt for 1 minute.
4443
RateLimiter::hit($key, 60);
4544

4645
UpdateUserIdenticonStatus::dispatchSync($user);

app/Models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function hasConnectedGitHubAccount(): bool
123123
return ! is_null($this->githubId());
124124
}
125125

126-
public function hasGithubIdenticon(): bool
126+
public function hasGitHubIdenticon(): bool
127127
{
128128
return (bool) $this->github_has_identicon;
129129
}
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
@props([
2-
'user',
3-
'unlinked' => false,
4-
'showRefresh' => false,
2+
'user',
3+
'unlinked' => false,
4+
'showRefresh' => false,
55
])
66

77
<?php
8-
$src = $user->githubId() && ! $user->hasGithubIdenticon()
8+
$src = $user->githubId() && ! $user->hasGitHubIdenticon()
99
? sprintf('https://avatars.githubusercontent.com/u/%s', $user->githubId())
1010
: asset('https://laravel.io/images/laravelio-icon-gray.svg');
1111
?>
1212

1313
<div class="relative inline-block">
1414
@unless ($unlinked)
15-
<a href="{{ route('profile', $user->username()) }}">
16-
@endunless
15+
<a href="{{ route('profile', $user->username()) }}">
16+
@endunless
1717

18-
<flux:avatar
19-
circle
20-
loading="lazy"
21-
src="{{ $src }}"
22-
alt="{{ $user->name() }}"
23-
{{ $attributes->merge(['class' => 'bg-gray-50']) }}
24-
/>
18+
<flux:avatar
19+
circle
20+
loading="lazy"
21+
src="{{ $src }}"
22+
alt="{{ $user->name() }}"
23+
{{ $attributes->merge(['class' => 'bg-gray-50']) }} />
2524

26-
@unless ($unlinked)
27-
</a>
25+
@unless ($unlinked)
26+
</a>
2827
@endunless
2928

3029
@if ($showRefresh && $user->hasConnectedGitHubAccount())
31-
<form method="POST" action="{{ route('avatar.refresh') }}" class="absolute bottom-[-1px] right-0">
32-
@csrf
33-
<button
34-
type="submit"
35-
class="flex items-center justify-center w-10 h-10 bg-white border-2 border-gray-300 rounded-full shadow-sm hover:bg-gray-50 hover:border-lio-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-lio-500 transition-colors"
36-
title="Refresh avatar from GitHub"
37-
>
38-
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
39-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
40-
</svg>
41-
</button>
42-
</form>
30+
<form method="POST" action="{{ route('avatar.refresh') }}" class="absolute bottom-[-1px] right-0">
31+
@csrf
32+
<button
33+
type="submit"
34+
class="flex items-center justify-center w-10 h-10 bg-white border-2 border-gray-300 rounded-full shadow-sm hover:bg-gray-50 hover:border-lio-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-lio-500 transition-colors"
35+
title="Refresh avatar from GitHub">
36+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
37+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
38+
</svg>
39+
</button>
40+
</form>
4341
@endif
44-
</div>
42+
</div>

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
Route::get('user/{username?}', [ProfileController::class, 'show'])->name('profile');
7171
Route::put('users/{username}/block', BlockUserController::class)->name('users.block');
7272
Route::put('users/{username}/unblock', UnblockUserController::class)->name('users.unblock');
73-
Route::post('/avatar/refresh', [ProfileController::class, 'refresh'])->name('avatar.refresh');
73+
Route::post('avatar/refresh', [ProfileController::class, 'refresh'])->name('avatar.refresh');
7474

7575
// Notifications
7676
Route::view('notifications', 'users.notifications')->name('notifications')->middleware(Authenticate::class);

0 commit comments

Comments
 (0)