Write default value to the database on getting the setting#7
Merged
kaiserkiwi merged 8 commits intoMay 12, 2026
Merged
Conversation
Info: I also fixed the minimum required PHP version as the illuminate packages require PHP 8.2+
…ing settings - For better readability I also move the now more complex logic to a fetchSetting method - Add missing trailing commas in multiple places Closes: #6
There was a problem hiding this comment.
Pull request overview
This PR updates the package for Laravel 13 compatibility and introduces an optional save_default configuration that can persist default values to the database when a setting is first read and missing. It also adds a Pest-based test suite and GitHub Actions CI to validate behavior across multiple PHP/Laravel versions.
Changes:
- Add
model_settings.save_default(andMODEL_SETTINGS_SAVE_DEFAULT) and implement “persist default on read” inHasSettings::getSetting(). - Add Pest + Orchestra Testbench test setup and feature tests for the settings trait.
- Add CI workflow to run tests across PHP 8.2–8.4 and Laravel 11–13.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/HasSettings.php |
Implements optional persistence of default values during getSetting() and refactors DB fetch logic. |
config/model_settings.php |
Adds save_default config key backed by env var. |
README.md |
Documents the new env/config option and behavior. |
tests/TestCase.php |
Adds Testbench base test case and in-memory SQLite migrations. |
tests/Pest.php |
Sets up Pest to use the package TestCase. |
tests/Models/TestUser.php |
Adds a minimal Eloquent model for trait testing. |
tests/Feature/HasSettingsTest.php |
Adds feature tests for HasSettings behavior (including save_default). |
.github/workflows/tests.yml |
Adds CI matrix to run tests on supported PHP/Laravel versions. |
phpunit.xml |
Adds PHPUnit configuration to support Pest runs and coverage source inclusion. |
composer.json |
Updates supported PHP/Laravel versions and adds test tooling dependencies/scripts. |
.gitignore |
Ignores PHPUnit result cache file. |
.editorconfig |
Extends editor defaults for JSON/YAML indentation and related settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1e83747 to
7770dee
Compare
- Optimize .editorconfig
7770dee to
0261728
Compare
Owner
Author
|
Tested it locally in my own projects. I didn't find any oddities. |
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.
Closes #6
This Pull Request makes the Plugin ready for Laravel 13, adds the option to write default values to the database (Disabled by default) and adds tests to the Package.
Features
save_defaultconfig to enable oder disabling saving the default value to the Database if it isn't there yetFixes
Tests
I finally added tests to the package so I don't have to guess if everything works as expected. I also added GitHub Actions.