Skip to content

Commit b3cee4b

Browse files
Refactor: Use strict comparison in chart widget filters
Replace loose equality (==) with strict equality (===) when comparing filter values in all chart widgets. This improves type safety and follows PHP best practices. Changed in 6 widget files: - RecentDownloadChartWidget - RecentUploadChartWidget - RecentPingChartWidget - RecentJitterChartWidget - RecentDownloadLatencyChartWidget - RecentUploadLatencyChartWidget
1 parent 4ac1891 commit b3cee4b

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

app/Filament/Widgets/RecentDownloadChartWidget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ protected function getData(): array
3838
$results = Result::query()
3939
->select(['id', 'download', 'created_at'])
4040
->where('status', '=', ResultStatus::Completed)
41-
->when($this->filter == '24h', function ($query) {
41+
->when($this->filter === '24h', function ($query) {
4242
$query->where('created_at', '>=', now()->subDay());
4343
})
44-
->when($this->filter == 'week', function ($query) {
44+
->when($this->filter === 'week', function ($query) {
4545
$query->where('created_at', '>=', now()->subWeek());
4646
})
47-
->when($this->filter == 'month', function ($query) {
47+
->when($this->filter === 'month', function ($query) {
4848
$query->where('created_at', '>=', now()->subMonth());
4949
})
5050
->orderBy('created_at')

app/Filament/Widgets/RecentDownloadLatencyChartWidget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ protected function getData(): array
3636
$results = Result::query()
3737
->select(['id', 'data', 'created_at'])
3838
->where('status', '=', ResultStatus::Completed)
39-
->when($this->filter == '24h', function ($query) {
39+
->when($this->filter === '24h', function ($query) {
4040
$query->where('created_at', '>=', now()->subDay());
4141
})
42-
->when($this->filter == 'week', function ($query) {
42+
->when($this->filter === 'week', function ($query) {
4343
$query->where('created_at', '>=', now()->subWeek());
4444
})
45-
->when($this->filter == 'month', function ($query) {
45+
->when($this->filter === 'month', function ($query) {
4646
$query->where('created_at', '>=', now()->subMonth());
4747
})
4848
->orderBy('created_at')

app/Filament/Widgets/RecentJitterChartWidget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ protected function getData(): array
3636
$results = Result::query()
3737
->select(['id', 'data', 'created_at'])
3838
->where('status', '=', ResultStatus::Completed)
39-
->when($this->filter == '24h', function ($query) {
39+
->when($this->filter === '24h', function ($query) {
4040
$query->where('created_at', '>=', now()->subDay());
4141
})
42-
->when($this->filter == 'week', function ($query) {
42+
->when($this->filter === 'week', function ($query) {
4343
$query->where('created_at', '>=', now()->subWeek());
4444
})
45-
->when($this->filter == 'month', function ($query) {
45+
->when($this->filter === 'month', function ($query) {
4646
$query->where('created_at', '>=', now()->subMonth());
4747
})
4848
->orderBy('created_at')

app/Filament/Widgets/RecentPingChartWidget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ protected function getData(): array
3737
$results = Result::query()
3838
->select(['id', 'ping', 'created_at'])
3939
->where('status', '=', ResultStatus::Completed)
40-
->when($this->filter == '24h', function ($query) {
40+
->when($this->filter === '24h', function ($query) {
4141
$query->where('created_at', '>=', now()->subDay());
4242
})
43-
->when($this->filter == 'week', function ($query) {
43+
->when($this->filter === 'week', function ($query) {
4444
$query->where('created_at', '>=', now()->subWeek());
4545
})
46-
->when($this->filter == 'month', function ($query) {
46+
->when($this->filter === 'month', function ($query) {
4747
$query->where('created_at', '>=', now()->subMonth());
4848
})
4949
->orderBy('created_at')

app/Filament/Widgets/RecentUploadChartWidget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ protected function getData(): array
3838
$results = Result::query()
3939
->select(['id', 'upload', 'created_at'])
4040
->where('status', '=', ResultStatus::Completed)
41-
->when($this->filter == '24h', function ($query) {
41+
->when($this->filter === '24h', function ($query) {
4242
$query->where('created_at', '>=', now()->subDay());
4343
})
44-
->when($this->filter == 'week', function ($query) {
44+
->when($this->filter === 'week', function ($query) {
4545
$query->where('created_at', '>=', now()->subWeek());
4646
})
47-
->when($this->filter == 'month', function ($query) {
47+
->when($this->filter === 'month', function ($query) {
4848
$query->where('created_at', '>=', now()->subMonth());
4949
})
5050
->orderBy('created_at')

app/Filament/Widgets/RecentUploadLatencyChartWidget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ protected function getData(): array
3636
$results = Result::query()
3737
->select(['id', 'data', 'created_at'])
3838
->where('status', '=', ResultStatus::Completed)
39-
->when($this->filter == '24h', function ($query) {
39+
->when($this->filter === '24h', function ($query) {
4040
$query->where('created_at', '>=', now()->subDay());
4141
})
42-
->when($this->filter == 'week', function ($query) {
42+
->when($this->filter === 'week', function ($query) {
4343
$query->where('created_at', '>=', now()->subWeek());
4444
})
45-
->when($this->filter == 'month', function ($query) {
45+
->when($this->filter === 'month', function ($query) {
4646
$query->where('created_at', '>=', now()->subMonth());
4747
})
4848
->orderBy('created_at')

0 commit comments

Comments
 (0)