2024-10-26 20:35:25 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2024-10-28 23:44:32 +01:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
2024-10-26 20:35:25 -04:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2024-10-28 23:44:32 +01:00
|
|
|
use Illuminate\Database\Eloquent\MassPrunable;
|
2024-10-26 20:35:25 -04:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2026-03-17 09:09:01 +01:00
|
|
|
use Illuminate\Support\Carbon;
|
2024-10-26 20:35:25 -04:00
|
|
|
|
2024-11-22 09:27:57 +01:00
|
|
|
/**
|
2026-03-17 09:09:01 +01:00
|
|
|
* @property int $id
|
|
|
|
|
* @property int $webhook_configuration_id
|
2024-11-22 09:27:57 +01:00
|
|
|
* @property string $event
|
|
|
|
|
* @property string $endpoint
|
2026-03-17 09:09:01 +01:00
|
|
|
* @property Carbon|null $successful_at
|
2025-03-03 14:41:19 -05:00
|
|
|
* @property array<array-key, mixed> $payload
|
2026-03-17 09:09:01 +01:00
|
|
|
* @property Carbon|null $created_at
|
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
|
*
|
|
|
|
|
* @method static Builder<static>|Webhook newModelQuery()
|
|
|
|
|
* @method static Builder<static>|Webhook newQuery()
|
|
|
|
|
* @method static Builder<static>|Webhook query()
|
|
|
|
|
* @method static Builder<static>|Webhook whereCreatedAt($value)
|
|
|
|
|
* @method static Builder<static>|Webhook whereEndpoint($value)
|
|
|
|
|
* @method static Builder<static>|Webhook whereEvent($value)
|
|
|
|
|
* @method static Builder<static>|Webhook whereId($value)
|
|
|
|
|
* @method static Builder<static>|Webhook wherePayload($value)
|
|
|
|
|
* @method static Builder<static>|Webhook whereSuccessfulAt($value)
|
|
|
|
|
* @method static Builder<static>|Webhook whereUpdatedAt($value)
|
|
|
|
|
* @method static Builder<static>|Webhook whereWebhookConfigurationId($value)
|
2024-11-22 09:27:57 +01:00
|
|
|
*/
|
2024-10-26 20:35:25 -04:00
|
|
|
class Webhook extends Model
|
|
|
|
|
{
|
2024-10-28 23:44:32 +01:00
|
|
|
use HasFactory, MassPrunable;
|
2024-10-26 20:35:25 -04:00
|
|
|
|
|
|
|
|
protected $fillable = ['payload', 'successful_at', 'event', 'endpoint'];
|
|
|
|
|
|
|
|
|
|
public function casts()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'payload' => 'array',
|
|
|
|
|
'successful_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-10-28 23:44:32 +01:00
|
|
|
|
|
|
|
|
public function prunable(): Builder
|
|
|
|
|
{
|
|
|
|
|
return static::where('created_at', '<=', Carbon::now()->subDays(config('panel.webhook.prune_days')));
|
|
|
|
|
}
|
2024-10-26 20:35:25 -04:00
|
|
|
}
|