Laraconfig icon indicating copy to clipboard operation
Laraconfig copied to clipboard

The setting [color] doesn't exist.

Open eafarooqi opened this issue 3 years ago • 2 comments

hi,

no matter what setting i create, i get the error setting doesn't exist. Laravel Version: 8.61.0 PHP 8

I can see the settings in table, they are enabled. Everything looks ok. Cache is disabled.

this is my user model

...
use DarkGhostHunter\Laraconfig\HasConfig;

class User extends Authenticatable implements LdapAuthenticatable
{
    use AuthenticatesWithLdap;
    use HasFactory, Notifiable;
    use HasLdapUser;
    use HasRoles;
    use HasConfig;
...

this is the settings/users.php file

<?php

use DarkGhostHunter\Laraconfig\Facades\Setting;

Setting::name('color')->string()->default('black');

This is how i am trying to get it. it always comes blank, even the value exists in database.

$user = User::find(1);
echo "Your color is: {$user->settings->get('color')}.";

if i try to set it i get setting doesn't exists, no matter how i try to set it.

$user = User::find(1);
$setting = $user->settings->get('color');

$setting->value = 'red';
$setting->save();

or

$user->settings->set([
    'color' => 'red'
]);

eafarooqi avatar Sep 21 '21 16:09 eafarooqi

i have investigated more and found out that in database the settable_type is getting saved without slashes. like: AppModelsUser it should be App\Models\User

Users already exists in database and the setting is initialized slashes are missing.

eafarooqi avatar Sep 22 '21 09:09 eafarooqi

Same here. Also see issue #29

divdax avatar Jan 11 '22 01:01 divdax