Skip to content

Commit 7f83a26

Browse files
committed
final tweaks
1 parent 8ef609b commit 7f83a26

File tree

14 files changed

+52
-30
lines changed

14 files changed

+52
-30
lines changed

app/Filament/Resources/Changelogs/ChangelogResource.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace App\Filament\Resources\Changelogs;
44

5-
use App\Filament\Resources\Changelogs\RelationManagers\ItemsRelationManager;
65
use Exception;
7-
use App\Models\Item;
86
use App\Models\Changelog;
97
use Filament\Tables\Table;
108
use Filament\Schemas\Schema;
@@ -24,6 +22,7 @@
2422
use App\Filament\Resources\Changelogs\Pages\EditChangelog;
2523
use App\Filament\Resources\Changelogs\Pages\ListChangelogs;
2624
use App\Filament\Resources\Changelogs\Pages\CreateChangelog;
25+
use App\Filament\Resources\Changelogs\RelationManagers\ItemsRelationManager;
2726

2827
class ChangelogResource extends Resource
2928
{

app/Filament/Resources/Changelogs/RelationManagers/ItemsRelationManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace App\Filament\Resources\Changelogs\RelationManagers;
44

5-
use App\Filament\Resources\Items\ItemResource;
5+
use Filament\Tables\Table;
66
use Filament\Actions\AttachAction;
7-
use Filament\Actions\BulkActionGroup;
87
use Filament\Actions\DetachAction;
8+
use Filament\Actions\BulkActionGroup;
99
use Filament\Actions\DetachBulkAction;
10+
use App\Filament\Resources\Items\ItemResource;
1011
use Filament\Resources\RelationManagers\RelationManager;
11-
use Filament\Tables\Table;
1212

1313
class ItemsRelationManager extends RelationManager
1414
{

app/Filament/Resources/Users/Pages/CreateUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use App\Mail\UserCreated;
66
use Illuminate\Support\Str;
7-
use Illuminate\Support\Facades\Mail;
87
use Illuminate\Support\Facades\Hash;
8+
use Illuminate\Support\Facades\Mail;
99
use Filament\Resources\Pages\CreateRecord;
1010
use App\Filament\Resources\Users\UserResource;
1111

app/Filament/Widgets/VoteHistoryChart.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class VoteHistoryChart extends ChartWidget
1212

1313
public ?Item $item = null;
1414

15+
public ?string $filter = 'all';
16+
1517
public function getHeading(): ?string
1618
{
1719
return trans('items.vote-history');
@@ -22,16 +24,36 @@ public function getDescription(): ?string
2224
return trans('items.vote-history-description');
2325
}
2426

27+
protected function getFilters(): ?array
28+
{
29+
return [
30+
'all' => trans('items.filter-all-time'),
31+
'7' => trans('items.filter-last-7-days'),
32+
'30' => trans('items.filter-last-30-days'),
33+
'90' => trans('items.filter-last-90-days'),
34+
'365' => trans('items.filter-last-year'),
35+
'730' => trans('items.filter-last-2-years'),
36+
'1095' => trans('items.filter-last-3-years'),
37+
];
38+
}
39+
2540
protected function getData(): array
2641
{
27-
if (!$this->item) {
42+
if (! $this->item) {
2843
return [
2944
'datasets' => [],
3045
'labels' => [],
3146
];
3247
}
3348

34-
$votes = $this->item->votes()
49+
$query = $this->item->votes();
50+
51+
if ($this->filter && $this->filter !== 'all') {
52+
$days = (int) $this->filter;
53+
$query->where('created_at', '>=', Carbon::now()->subDays($days));
54+
}
55+
56+
$votes = $query
3557
->selectRaw('DATE(created_at) as date, COUNT(*) as count')
3658
->groupByRaw('DATE(created_at)')
3759
->orderBy('date')
@@ -54,7 +76,7 @@ protected function getData(): array
5476
$currentDate = $startDate->copy();
5577
while ($currentDate->lte($endDate)) {
5678
$dateKey = $currentDate->format('Y-m-d');
57-
$labels[] = $currentDate->format('M d');
79+
$labels[] = $currentDate->format('M d, Y');
5880
$data[] = $votesMap[$dateKey] ?? 0;
5981
$currentDate->addDay();
6082
}

app/Livewire/SpotlightSearch.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
use App\Models\Item;
66
use App\Models\Project;
7-
use Illuminate\Support\Collection;
8-
use Livewire\Attributes\On;
97
use Livewire\Component;
8+
use Livewire\Attributes\On;
109

1110
class SpotlightSearch extends Component
1211
{

app/Mail/UserCreated.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
7-
use Illuminate\Contracts\Queue\ShouldQueue;
87
use Illuminate\Mail\Mailable;
98
use Illuminate\Mail\Mailables\Content;
10-
use Illuminate\Mail\Mailables\Envelope;
119
use Illuminate\Queue\SerializesModels;
10+
use Illuminate\Mail\Mailables\Envelope;
11+
use Illuminate\Contracts\Queue\ShouldQueue;
1212

1313
class UserCreated extends Mailable implements ShouldQueue
1414
{

lang/en/items.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@
3535
'update-board-success' => 'Successfully moved the item to board :board',
3636
'view-on-github' => 'View issue on GitHub',
3737
'search-shortcut' => 'CMD + K to search',
38-
'view-vote-history' => 'View vote history',
39-
'vote-history' => 'Vote history',
38+
'view-vote-history' => 'View voting history',
39+
'vote-history' => 'Voting history',
4040
'vote-history-description' => 'See how votes have been added over time.',
4141
'votes-per-day' => 'Votes',
4242
'no-vote-history' => 'No votes have been recorded yet.',
43+
'filter-all-time' => 'All time',
44+
'filter-last-7-days' => 'Last 7 days',
45+
'filter-last-30-days' => 'Last 30 days',
46+
'filter-last-90-days' => 'Last 90 days',
47+
'filter-last-year' => 'Last year',
48+
'filter-last-2-years' => 'Last 2 years',
49+
'filter-last-3-years' => 'Last 3 years',
4350
];

lang/en/mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
'help-text' => 'If you have any questions or need assistance, feel free to reach out to our support team.',
1515
'closing' => 'Best regards',
1616
],
17-
];
17+
];

lang/nl/mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
'help-text' => 'Als je vragen hebt of hulp nodig hebt, neem gerust contact op met ons supportteam.',
1515
'closing' => 'Met vriendelijke groet',
1616
],
17-
];
17+
];

resources/views/livewire/item/vote-button.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
<span
2626
class="text-sm">{{ trans_choice('messages.total-votes', $model->total_votes, ['votes' => $model->total_votes]) }}</span>
2727

28-
<livewire:item.vote-history :item="$model" />
28+
@if($model instanceof \App\Models\Item)
29+
<livewire:item.vote-history :item="$model" />
30+
@endif
2931

3032
@if($vote && $showSubscribeOption)
3133
@if($vote->subscribed)

0 commit comments

Comments
 (0)