Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"require": {
"php": "^8.2",
"doctrine/dbal": "^3.6",
"filament/filament": "^3.2.23",
"filament/filament": "^3.2.57",
"filament/spatie-laravel-settings-plugin": "^3.2",
"guzzlehttp/guzzle": "^7.8",
"illuminate/console": "^11.0",
"illuminate/database": "^11.0",
"illuminate/events": "^11.0",
"illuminate/queue": "^11.0",
"illuminate/support": "^11.0",
"illuminate/console": "^11.23.0",
"illuminate/database": "^11.23.0",
"illuminate/events": "^11.23.0",
"illuminate/queue": "^11.23.0",
"illuminate/support": "^11.23.0",
"nesbot/carbon": "^2.70",
"spatie/laravel-data": "^4.11",
"spatie/laravel-query-builder": "^5.5",
Expand All @@ -37,7 +37,7 @@
"twig/twig": "^3.0"
},
"require-dev": {
"larastan/larastan": "^2.9",
"larastan/larastan": "^3.0",
"laravel/pail": "^1.1",
"orchestra/testbench": "^9.5.1",
"pestphp/pest": "^3.2",
Expand Down
2 changes: 1 addition & 1 deletion config/cachet.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
| This is the model that will be used to authenticate users. This model
| must be an instance of Illuminate\Foundation\Auth\User.
*/
'user_model' => App\Models\User::class,
'user_model' => \App\Models\User::class,

/*
|--------------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,21 @@ public function run(): void
'visible' => ResourceVisibilityEnum::guest,
]);

/** @phpstan-ignore-next-line argument.type Larastan bug */
$componentGroup->components()->createMany([
[
'name' => 'Cachet Website',
'description' => 'The Cachet website.',
'link' => 'https://cachethq.io',
'status' => ComponentStatusEnum::operational,
], [
],
[
'name' => 'Cachet Documentation',
'description' => 'The Cachet docs, powered by Mintlify.',
'link' => 'https://docs.cachethq.io',
'status' => ComponentStatusEnum::operational,
], [
],
[
'name' => 'Cachet Blog',
'description' => 'Learn more about Cachet.',
'link' => 'https://blog.cachethq.io',
Expand Down
66 changes: 0 additions & 66 deletions phpstan-baseline.neon

This file was deleted.

10 changes: 7 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
includes:
- vendor/larastan/larastan/extension.neon
- phpstan-baseline.neon

parameters:
level: 5

paths:
- src
- routes
- config
- database/factories
- database/seeders

Expand All @@ -18,4 +16,10 @@ parameters:
- public

databaseMigrationsPath:
- database/migrations
- database/migrations

ignoreErrors:
-
path: src/Http/Resources
identifier: return.type
message: '#Method Cachet\\Http\\Resources\\.*?::toRelationships\(\).*#'
6 changes: 3 additions & 3 deletions src/Actions/Metric/CreateMetricPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public function handle(Metric $metric, ?CreateMetricPointData $data = null): Met
$lastPoint = $metric->metricPoints()->latest()->first();

// If the last point was created within the threshold, increment the counter.
if ($lastPoint && $lastPoint->withinThreshold($metric->threshold, $data?->timestamp ?? null)) {
if ($lastPoint && $lastPoint->withinThreshold($metric->threshold, $data->timestamp ?? null)) {
$lastPoint->increment('counter');

return $lastPoint;
}

return $metric->metricPoints()->create([
'value' => $data?->value ?? $metric->default_value,
'value' => $data->value ?? $metric->default_value,
'counter' => 1,
'created_at' => $data?->timestamp ?? now(),
'created_at' => $data->timestamp ?? now(),
]);
}
}
4 changes: 2 additions & 2 deletions src/Enums/ComponentGroupVisibilityEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getLabel(): string
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::expanded => 'heroicon-o-chevron-down',
Expand All @@ -30,7 +30,7 @@ public function getIcon(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): string
{
return 'gray';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Enums/ComponentStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getLabel(): string
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::operational => 'cachet-circle-check',
Expand All @@ -46,7 +46,7 @@ public function getIcon(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): array
{
return match ($this) {
self::operational => Color::Green,
Expand Down
8 changes: 4 additions & 4 deletions src/Enums/ExternalProviderEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ enum ExternalProviderEnum: string
*/
public function status(mixed $status): IncidentStatusEnum
{
if ($this === self::OhDear) {
return match ($status) {
return match ($this) {
self::OhDear => match ($status) {
'resolved' => IncidentStatusEnum::fixed,
'warning' => IncidentStatusEnum::investigating,
default => IncidentStatusEnum::unknown,
};
}
},
};
}
}
4 changes: 2 additions & 2 deletions src/Enums/IncidentStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getLabel(): string
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::investigating => 'cachet-incident-investigating',
Expand All @@ -57,7 +57,7 @@ public function getIcon(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): array
{
return match ($this) {
self::investigating => Color::Blue,
Expand Down
6 changes: 3 additions & 3 deletions src/Enums/IncidentTemplateEngineEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ enum IncidentTemplateEngineEnum: string implements HasColor, HasIcon, HasLabel
case blade = 'blade';
case twig = 'twig';

public function getColor(): string|array|null
public function getColor(): array
{
return match ($this) {
self::blade => Color::rgb('rgb(249, 50, 44)'),
self::twig => Color::Zinc,
};
}

public function getLabel(): ?string
public function getLabel(): string
{
return match ($this) {
self::blade => __('Laravel Blade'),
self::twig => __('Twig'),
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::blade => 'cachet-laravel',
Expand Down
4 changes: 2 additions & 2 deletions src/Enums/MetricTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ enum MetricTypeEnum: int implements HasIcon, HasLabel
case sum = 0;
case average = 1;

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::sum => 'cachet-metrics',
self::average => 'cachet-metrics',
};
}

public function getLabel(): ?string
public function getLabel(): string
{
return match ($this) {
self::sum => __('Sum'),
Expand Down
4 changes: 2 additions & 2 deletions src/Enums/MetricViewEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function getLabel(): string
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::last_hour => 'cachet-metrics',
Expand All @@ -33,7 +33,7 @@ public function getIcon(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): string
{
return 'info';
}
Expand Down
6 changes: 3 additions & 3 deletions src/Enums/ResourceVisibilityEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function visibleToUsers(): array
return [self::authenticated, self::guest];
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::authenticated => 'heroicon-o-lock-closed',
Expand All @@ -31,7 +31,7 @@ public function getIcon(): ?string
};
}

public function getLabel(): ?string
public function getLabel(): string
{
return match ($this) {
self::authenticated => __('Users'),
Expand All @@ -40,7 +40,7 @@ public function getLabel(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): string
{
return match ($this) {
self::authenticated => 'warning',
Expand Down
4 changes: 2 additions & 2 deletions src/Enums/ScheduleStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getLabel(): string
};
}

public function getColor(): string|array|null
public function getColor(): array
{
return match ($this) {
self::upcoming => Color::Blue,
Expand All @@ -53,7 +53,7 @@ public function getColor(): string|array|null
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::complete => 'cachet-circle-check',
Expand Down
6 changes: 3 additions & 3 deletions src/Enums/SystemStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum SystemStatusEnum implements HasColor, HasIcon, HasLabel
case partial_outage;
case major_outage;

public function getLabel(): ?string
public function getLabel(): string
{
return match ($this) {
self::operational => __('All systems are operational.'),
Expand All @@ -22,7 +22,7 @@ public function getLabel(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): array
{
return match ($this) {
self::operational => Color::Green,
Expand All @@ -31,7 +31,7 @@ public function getColor(): string|array|null
};
}

public function getIcon(): ?string
public function getIcon(): string
{
return match ($this) {
self::operational => 'heroicon-m-check-circle',
Expand Down
6 changes: 4 additions & 2 deletions src/Http/Controllers/Api/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ class IncidentController extends Controller
*/
public function index()
{
$incidents = QueryBuilder::for(Incident::class)
$query = Incident::query()
->when(! request('sort'), function (Builder $builder) {
$builder->orderByDesc('created_at');
})
});

$incidents = QueryBuilder::for($query)
->allowedIncludes(self::ALLOWED_INCLUDES)
->allowedFilters(['name', 'status', 'occurred_at'])
->allowedSorts(['name', 'status', 'id'])
Expand Down
Loading
Loading