Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

The setting [color] doesn't exist. #22

Open
eafarooqi opened this issue Sep 21, 2021 · 2 comments
Open

The setting [color] doesn't exist. #22

eafarooqi opened this issue Sep 21, 2021 · 2 comments

Comments

@eafarooqi
Copy link
Contributor

eafarooqi commented Sep 21, 2021

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
Copy link
Contributor Author

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.

@divdax
Copy link

divdax commented Jan 11, 2022

Same here. Also see issue #29

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants