Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -38,18 +38,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\WebhookMessage
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property int $webhook_id
* @property bool $sent
* @property bool $errored
* @property int $attempts
* @property string $uuid
* @property array $message
* @property array|null $logs
* @property-read Webhook $webhook
* @property int $id
* @property null|Carbon $created_at
* @property null|Carbon $updated_at
* @property null|string $deleted_at
* @property int $webhook_id
* @property bool $sent
* @property bool $errored
* @property int $attempts
* @property string $uuid
* @property array $message
* @property null|array $logs
* @property Webhook $webhook
*
* @method static Builder|WebhookMessage newModelQuery()
* @method static Builder|WebhookMessage newQuery()
* @method static Builder|WebhookMessage query()
@@ -64,8 +65,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|WebhookMessage whereUpdatedAt($value)
* @method static Builder|WebhookMessage whereUuid($value)
* @method static Builder|WebhookMessage whereWebhookId($value)
* @property-read Collection|WebhookAttempt[] $webhookAttempts
* @property-read int|null $webhook_attempts_count
*
* @property Collection|WebhookAttempt[] $webhookAttempts
* @property null|int $webhook_attempts_count
*
* @mixin Eloquent
*/
class WebhookMessage extends Model
@@ -84,37 +87,31 @@ class WebhookMessage extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return WebhookMessage
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$messageId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var WebhookMessage|null $message */
/** @var null|WebhookMessage $message */
$message = self::find($messageId);
if (null !== $message && $message->webhook->user_id === $user->id) {
return $message;
}
}
throw new NotFoundHttpException();
}
/**
* @return BelongsTo
*/
public function webhook(): BelongsTo
{
return $this->belongsTo(Webhook::class);
}
/**
* @return HasMany
*/
public function webhookAttempts(): HasMany
{
return $this->hasMany(WebhookAttempt::class);
@@ -122,23 +119,18 @@ class WebhookMessage extends Model
/**
* Get the amount
*
* @return Attribute
*/
protected function sent(): Attribute
{
return Attribute::make(
get: static fn($value) => (bool)$value,
get: static fn ($value) => (bool)$value,
);
}
/**
* @return Attribute
*/
protected function webhookId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}