Implement webhook inspector

This commit is contained in:
2026-08-04 17:09:39 +02:00
parent b021836c14
commit 75d8b25b64
57 changed files with 5110 additions and 230 deletions
@@ -0,0 +1,62 @@
<?php
namespace Database\Factories;
use App\Models\User;
use App\Models\WebhookEndpoint;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<WebhookEndpoint>
*/
class WebhookEndpointFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$token = Str::random(48);
return [
'user_id' => null,
'name' => 'Test endpoint',
'token' => $token,
'token_hash' => WebhookEndpoint::tokenHash($token),
'is_public' => true,
'is_active' => true,
'expires_at' => now()->addDays((int) config('webhooks.anonymous_ttl_days', 7)),
'response_status' => 200,
'response_headers' => ['Content-Type' => 'application/json'],
'response_body' => '{}',
'last_request_at' => null,
];
}
public function ownedBy(User $user): static
{
return $this->state(fn (array $attributes): array => [
'user_id' => $user->getKey(),
'name' => 'Private endpoint',
'is_public' => false,
'expires_at' => null,
]);
}
public function expired(): static
{
return $this->state(fn (array $attributes): array => [
'expires_at' => now()->subMinute(),
]);
}
public function inactive(): static
{
return $this->state(fn (array $attributes): array => [
'is_active' => false,
]);
}
}