Skip to content

Respect the configured webhook_model table when storing webhooks#256

Merged
freekmurze merged 1 commit into
mainfrom
webhook-call-respects-configured-model
Jun 4, 2026
Merged

Respect the configured webhook_model table when storing webhooks#256
freekmurze merged 1 commit into
mainfrom
webhook-call-respects-configured-model

Conversation

@freekmurze

Copy link
Copy Markdown
Member

Context

This grew out of #253. The issue claimed storeWebhook() ignores the configured webhook_model because of self::create(...). That specific claim is incorrect: self::create() is a forwarding static call, and Eloquent's Model::__callStatic() uses new static, so the model is created against the configured class regardless.

However, while verifying that, I found a real self-vs-static bug introduced with the attachments column (#249):

if (Schema::hasColumn((new self())->getTable(), 'attachments')) {

new self() always builds a base WebhookCall, so for a custom webhook_model mapped to a different table, the attachments-column check probes the base table instead of the configured model's table. A custom model whose table lacks the attachments column (while the default webhook_calls table has it) then tries to insert an attachments column that doesn't exist, and the write fails.

Changes

  • Use static:: / new static() throughout storeWebhook() and its static helpers, so late static binding resolves to the configured model (matching the existing static::where(...) in prunable()).
  • Add a regression test that stores through a custom-table model whose table has no attachments column while the default table does. It fails on main (SQL error on insert) and passes with this change.

Testing

  • vendor/bin/pest → 37 passed (was 36).
  • vendor/bin/phpstan analyse → no errors (verified in the CI environment: PHP 8.3 / Laravel 13 / Symfony 7).

storeWebhook() checked for the attachments column with
Schema::hasColumn((new self())->getTable(), ...). Because self resolves
to WebhookCall, a custom webhook_model mapped to a different table had
its attachments-column probe run against the base table instead of its
own, so storing could attempt to write an attachments column the custom
table does not have (or skip one it does).

Use static:: / new static() throughout the static helpers so late static
binding resolves to the configured model. Add a regression test storing
through a custom-table model whose table has no attachments column while
the default table does.

Refs #253.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@freekmurze freekmurze merged commit a2c2474 into main Jun 4, 2026
11 checks passed
@freekmurze freekmurze deleted the webhook-call-respects-configured-model branch June 4, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant