I have an existing codebase with many users already in the database. When I retrieve one of these existing users, their settings are not initialised. This results in the following error when I attempt to set the value of a setting on one of these users:
use App\Models\User;
$user = User::find(1);
$user->settings->set('dark_mode', true);
// RuntimeException with message 'The setting [dark_mode] doesn't exist.'
I have created a PR which resolves this by hooking into the retrieved Eloquent event within the HasConfig trait.
PR: Initialise when loading historic user records