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
2 changes: 1 addition & 1 deletion src/Filament/Widgets/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function fetchFeed(string $uri, int $maxPosts = 5): array
try {
$response = Http::get($uri);

$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->body());

$posts = [];

Expand Down
6 changes: 3 additions & 3 deletions src/Http/Resources/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function toAttributes(Request $request): array
'human' => $this->updated_at?->diffForHumans(),
'string' => $this->updated_at?->toDateTimeString(),
],
'pivot' => $this->when(isset($this->pivot) && isset($this->pivot->component_status), function () {
'pivot' => $this->when($this->pivot?->component_status !== null, function () {
return [
'component_status' => [
'human' => $this->pivot->component_status->getLabel(),
'value' => $this->pivot->component_status->value,
'human' => $this->pivot->component_status?->getLabel(),
'value' => $this->pivot->component_status?->value,
],
];
}),
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Incident.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Incident extends Model
'occurred_at' => 'datetime',
];

/** @var array<string, string> */
/** @var array<string, class-string> */
protected $dispatchesEvents = [
'created' => IncidentCreated::class,
'deleted' => IncidentDeleted::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Metric extends Model
'order' => 'int',
];

/** @var array<string, string> */
/** @var array<string, class-string> */
protected $dispatchesEvents = [
'created' => MetricCreated::class,
'deleted' => MetricDeleted::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Models/MetricPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MetricPoint extends Model
'value' => 'float',
];

/** @var array<string, string> */
/** @var array<string, class-string> */
protected $dispatchesEvents = [
'created' => MetricPointCreated::class,
'deleted' => MetricPointDeleted::class,
Expand Down
5 changes: 3 additions & 2 deletions src/Models/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ protected function status(): Attribute
/**
* Get the components affected by this schedule.
*
* @return BelongsToMany<Component, $this>
* @return BelongsToMany<Component, $this, ScheduleComponent>
*/
public function components(): BelongsToMany
{
return $this->belongsToMany(
Component::class,
'schedule_components',
)->withPivot(['component_status'])
)->using(ScheduleComponent::class)
->withPivot(['component_status'])
->withTimestamps();
}

Expand Down
17 changes: 9 additions & 8 deletions src/Models/ScheduleComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@
namespace Cachet\Models;

use Cachet\Database\Factories\ScheduleComponentFactory;
use Cachet\Enums\ComponentStatusEnum;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;

/**
* @property int $id
* @property int $schedule_id
* @property int $component_id
* @property int $component_status
* @property ?ComponentStatusEnum $component_status
* @property ?Carbon $created_at
* @property ?Carbon $updated_at
* @property Schedule $schedule
* @property Component $component
*
* @method static ScheduleComponentFactory factory($count = null, $state = [])
*/
class ScheduleComponent extends Model
class ScheduleComponent extends Pivot
{
protected $table = 'schedule_components';

/** @use HasFactory<ScheduleComponentFactory> */
use HasFactory;

/** @var list<string> */
protected $fillable = [
'schedule_id',
'component_id',
'component_status',
/** @var array<string, string> */
protected $casts = [
'component_status' => ComponentStatusEnum::class,
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Subscriber extends Model
'verified_at' => 'datetime',
];

/** @var array<string, string> */
/** @var array<string, class-string> */
protected $dispatchesEvents = [
'created' => SubscriberCreated::class,
'deleted' => SubscriberUnsubscribed::class,
Expand Down