Skip to content

Commit d491e37

Browse files
author
Hatim EL OUFIR
committed
Add comments count to kanban board
1 parent 697c03b commit d491e37

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

app/Http/Livewire/Kanban.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ protected function statuses(): Collection
3434
*/
3535
protected function records(): Collection
3636
{
37-
return Ticket::all()
37+
$query = Ticket::query();
38+
$query->withCount('comments');
39+
if (has_all_permissions(auth()->user(), 'view-own-tickets') && !has_all_permissions(auth()->user(), 'view-all-tickets')) {
40+
$query->where(function ($query) {
41+
$query->where('owner_id', auth()->user()->id)
42+
->orWhere('responsible_id', auth()->user()->id);
43+
});
44+
}
45+
return $query->get()
3846
->map(function (Ticket $ticket) {
3947
$priority = config('system.priorities.' . $ticket->priority);
4048
$type = config('system.types.' . $ticket->type);
@@ -54,13 +62,19 @@ protected function records(): Collection
5462
<div class="w-full text-xs font-light">
5563
' . Str::limit(htmlspecialchars(strip_tags($ticket->content))) . '
5664
</div>
57-
<div class="w-full flex items-center gap-1">
58-
'.
59-
($ticket->responsible ? '
60-
<img src="' . $ticket->responsible->avatar_url . '" alt="' . $ticket->responsible->name . '" class="rounded-full shadow" style="width: 20px; height: 20px;" />
61-
<span class="font-light text-xs">' . $ticket->responsible->name . '</span>
62-
' : '<span class="text-xs font-normal text-gray-400">' . __('Not assigned yet!') . '</span>')
63-
.'
65+
<div class="w-full flex items-center space-x-4">
66+
<div class="flex items-center gap-1">
67+
'.
68+
($ticket->responsible ? '
69+
<img src="' . $ticket->responsible->avatar_url . '" alt="' . $ticket->responsible->name . '" class="rounded-full shadow" style="width: 20px; height: 20px;" />
70+
<span class="font-light text-xs">' . $ticket->responsible->name . '</span>
71+
' : '<span class="text-xs font-normal text-gray-400">' . __('Not assigned yet!') . '</span>')
72+
.'
73+
</div>
74+
<div class="flex items-center gap-1 text-xs text-gray-500">
75+
' . $ticket->comments_count . '
76+
<i class="fa fa-comment-o"></i>
77+
</div>
6478
</div>
6579
</div>
6680
'),

0 commit comments

Comments
 (0)