Manage webhooks from the panel
Create one and see its secret once, send a test, change the secret, and read each delivery with what the other end answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
app/Filament/Resources/Webhooks/Pages/CreateWebhook.php
Normal file
44
app/Filament/Resources/Webhooks/Pages/CreateWebhook.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Webhooks\Pages;
|
||||
|
||||
use App\Filament\Resources\Webhooks\WebhookResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* The secret is made here and shown once, on the page that opens next.
|
||||
*/
|
||||
class CreateWebhook extends CreateRecord
|
||||
{
|
||||
protected static string $resource = WebhookResource::class;
|
||||
|
||||
protected string $secret = '';
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$this->secret = Str::random(40);
|
||||
|
||||
return [...$data, 'secret' => $this->secret];
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$this->record->forceFill(['created_by' => Auth::id()])->save();
|
||||
|
||||
WebhookResource::showSecret($this->secret);
|
||||
}
|
||||
|
||||
protected function getCreatedNotification(): null
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return WebhookResource::getUrl('edit', ['record' => $this->record]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user