Skip to content

Add table and model config options - #22

Open
guiribmedeiros wants to merge 1 commit into
saloonphp:mainfrom
guiribmedeiros:feature/configurable-table-and-model
Open

guiribmedeiros wants to merge 1 commit into
saloonphp:mainfrom
guiribmedeiros:feature/configurable-table-and-model

Conversation

@guiribmedeiros

@guiribmedeiros guiribmedeiros commented Nov 12, 2026 •

Copy link
Copy Markdown

Overview of change

Adds two config options so Barstool can follow an app's own naming conventions.

  • table: the table recordings are stored in. Defaults to barstools. The model and all three migration stubs use it.
  • model: the model recordings are written through, both inline and from the queued job. Defaults to Saloon\Barstool\Models\Barstool. A custom model must extend it, and it gets the configured table automatically. Without that, Eloquent would infer saloon_logs from a SaloonLog subclass.
'table' => 'saloon_logs',
'model' => App\Models\SaloonLog::class,

This is fully backwards compatible. The defaults match current behaviour, and a published config without these keys falls back to the same defaults. Migrations that are already published are untouched.

A few notes:

  • The model is resolved through Barstool::getModelClass(). It is marked @internal so it doesn't add to the public API.
  • The add_created_at_index upgrade migration now looks for an existing index by column (hasIndex($table, ['created_at'])) instead of by the generated barstools_created_at_index name. That way the check works for any table name.
  • Nothing checks at runtime that the configured model extends the default one; the config comment states the requirement. I'm happy to add an is_a() guard if you'd prefer one.
  • The README has a new "Custom table & model" section. I didn't touch the CHANGELOG.

Testing

Four new tests:

  • Recording into a custom table created by the create migration.
  • The upgrade migrations target the configured table, including re-running the index migration without adding a duplicate index.
  • Recording through a custom model, both synchronously and through the queue.

All four fail without the change. Full suite: 51 passed (196 assertions) on Laravel 13 and Laravel 12. PHPStan level 8 and Pint are both clean. The branch also merges cleanly with #21.

🤖 Generated with Claude Code

Adds `table` and `model` config options so recordings can be stored in a
custom table and recorded through a custom model that extends the default
Barstool model. Defaults match the current behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@guiribmedeiros

Copy link
Copy Markdown
Author

@craigpotter may I ask you for a review? great tools btw!

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