Skip to content

Commit aa3ab10

Browse files
authored
fix: (LAR-154) fixing bug when displaying user thread suscription (#287)
Correction du bug sur l'affichage des sujets suivi par l'utilisateur connecté
2 parents 441ee73 + 082a20b commit aa3ab10

File tree

8 files changed

+124
-135
lines changed

8 files changed

+124
-135
lines changed

app/Http/Controllers/Api/Auth/RegisterController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function register(RegisterRequest $request): JsonResponse
3131

3232
$user->assignRole('company');
3333

34-
//TODO: Send new company registration notification on Slack
34+
// TODO: Send new company registration notification on Slack
3535
event(new ApiRegistered($user));
3636

3737
return response()->json(
@@ -81,9 +81,9 @@ public function googleAuthenticator(Request $request): JsonResponse
8181
'avatar' => $socialUser['photoUrl'],
8282
]);
8383

84-
//TODO: Send welcome email to user 1 hour after registration
84+
// TODO: Send welcome email to user 1 hour after registration
8585

86-
//TODO: Send new company registration notification on Slack
86+
// TODO: Send new company registration notification on Slack
8787

8888
$user->last_login_at = Carbon::now();
8989
$user->last_login_ip = $request->ip();

app/Livewire/Pages/Forum/Index.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class Index extends Component
3636
#[Url(as: 'no-replies')]
3737
public ?string $unAnswered = null;
3838

39-
#[Url]
39+
#[Url(as: 'follow')]
4040
public ?string $subscribe = null;
4141

4242
public ?Channel $currentChannel = null;
@@ -129,6 +129,12 @@ protected function applyChannel(Builder $query): Builder
129129

130130
protected function applySubscribe(Builder $query): Builder
131131
{
132+
if (Auth::check() && $this->subscribe) {
133+
$query->whereHas('subscribes', function (Builder $query): void {
134+
$query->where('user_id', Auth::id());
135+
});
136+
}
137+
132138
return $query;
133139
}
134140

app/Models/User.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,8 @@ public function scopeWithCounts(Builder $query): Builder
477477
'articles as articles_count',
478478
'threads as threads_count',
479479
'replyAble as replies_count',
480-
'replyAble as solutions_count' => function (Builder $query) {
481-
return $query->join('threads', 'threads.solution_reply_id', '=', 'replies.id')
482-
->where('replyable_type', 'thread');
483-
},
480+
'replyAble as solutions_count' => fn (Builder $query) => $query->join('threads', 'threads.solution_reply_id', '=', 'replies.id')
481+
->where('replyable_type', 'thread'),
484482
]);
485483
}
486484

app/Widgets/MostActiveUsersPerWeek.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ public function run(): View
3333
$users = User::with('activities')
3434
->withCount('activities')
3535
->verifiedUsers()
36-
->whereHas('activities', function (Builder $query) {
37-
return $query->whereBetween('created_at', [
38-
now()->startOfWeek(),
39-
now()->endOfWeek(),
40-
]);
41-
})
36+
->whereHas('activities', fn (Builder $query) => $query->whereBetween('created_at', [
37+
now()->startOfWeek(),
38+
now()->endOfWeek(),
39+
]))
4240
->orderByDesc('activities_count')
4341
->limit(5)
4442
->get();

0 commit comments

Comments
 (0)