*/ class WebhookEndpointFactory extends Factory { /** * Define the model's default state. * * @return array */ 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, ]); } }