This repository was archived by the owner on Feb 18, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
Column not found: 1054 Unknown column 'theme' in 'field list' #36
Copy link
Copy link
Open
Description
When initialising the settings I get this error:
Column not found: 1054 Unknown column 'theme' in 'field list' (SQL: insert into user_settings (settable_id, settable_type, metadata_id, theme, updated_at, created_at) values (1, App\Models\Company, 1, dark, 2022-02-15 10:01:07, 2022-02-15 10:01:07))
users.php:
Setting::name('display_name')->boolean()->default(false);
Setting::name('theme')->array()->default(['theme' => 'dark'])->group('companies')->bag('companies');Initialization:
$user = User::first();
$user->company->settings()->initialize();
$user->settings()->initialize();I'm initialising because I use a seeder to create the models.
I have migrated the settings and company is another model connected to user model by foreign ID.
User model:
namespace App\Models;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use DarkGhostHunter\Laraconfig\HasConfig;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasConfig;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'company_id'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function company()
{
return $this->belongsTo(Company::class);
}
}Company model:
namespace App\Models;
use DarkGhostHunter\Laraconfig\HasConfig;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
use HasFactory, HasConfig;
protected $fillable = [
'name',
];
}Am I missing something?
Note: I was able to create user settings but when I added company that's when the error started.
Versions:
- "laravel/framework": "^8.75",
- "darkghosthunter/laraconfig": "^1.3.5",
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels