mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Code cleanup.
This commit is contained in:
@@ -37,15 +37,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class WebhookAttempt
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int $webhook_message_id
|
||||
* @property int|string $status_code
|
||||
* @property string|null $logs
|
||||
* @property string|null $response
|
||||
* @property-read WebhookMessage $webhookMessage
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property int $webhook_message_id
|
||||
* @property int|string $status_code
|
||||
* @property null|string $logs
|
||||
* @property null|string $response
|
||||
* @property WebhookMessage $webhookMessage
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt query()
|
||||
@@ -57,9 +58,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt whereStatusCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt whereWebhookMessageId($value)
|
||||
* @method static Builder|WebhookAttempt onlyTrashed()
|
||||
* @method static Builder|WebhookAttempt withTrashed()
|
||||
* @method static Builder|WebhookAttempt withoutTrashed()
|
||||
* @method static Builder|WebhookAttempt onlyTrashed()
|
||||
* @method static Builder|WebhookAttempt withTrashed()
|
||||
* @method static Builder|WebhookAttempt withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class WebhookAttempt extends Model
|
||||
@@ -70,41 +72,35 @@ class WebhookAttempt extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return WebhookAttempt
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$attemptId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var WebhookAttempt|null $attempt */
|
||||
|
||||
/** @var null|WebhookAttempt $attempt */
|
||||
$attempt = self::find($attemptId);
|
||||
if (null !== $attempt && $attempt->webhookMessage->webhook->user_id === $user->id) {
|
||||
return $attempt;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function webhookMessage(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebhookMessage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function webhookMessageId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user