Respect the configured webhook_model table when storing webhooks#256
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This grew out of #253. The issue claimed
storeWebhook()ignores the configuredwebhook_modelbecause ofself::create(...). That specific claim is incorrect:self::create()is a forwarding static call, and Eloquent'sModel::__callStatic()usesnew 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):
new self()always builds a baseWebhookCall, so for a customwebhook_modelmapped 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 theattachmentscolumn (while the defaultwebhook_callstable has it) then tries to insert anattachmentscolumn that doesn't exist, and the write fails.Changes
static::/new static()throughoutstoreWebhook()and its static helpers, so late static binding resolves to the configured model (matching the existingstatic::where(...)inprunable()).attachmentscolumn while the default table does. It fails onmain(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).