我正在尝试在 Laravel 5.3 上构建一个应用程序,其中我的模型、数据库和控制器位于不同的文件夹中。我有以下文件夹结构:
Nitseditor
System
Controllers
Database
2016_12_28_130149_create_domains_table.php
2017_01_06_193355_create_themes_table.php
2017_01_07_140804_create_themes_domains_table.php
Models
Domain.php
Theme.php
我正在与多对多关系的域建立关系,即
public function themes()
{
return $this->belongsToMany('Nitseditor\System\Models\Domain');
}
我已将表命名domain_theme
为2017_01_07_140804_create_themes_domains_table.php
现在我正在尝试获取属于控制器中域的主题名称,如下所示:
$flashmesage = new Domain;
foreach ($flashmesage->themes as $theme)
{
return $theme->theme_name;
}
我收到一个错误:
SQLSTATE [42S02]:未找到基表或视图:1146 表 'nitswebbuilder.domain_domain' 不存在(SQL:选择
domains
.*,domain_domain
.domain_id
aspivot_domain_id
fromdomains
inner joindomain_domain
ondomains
.id
=domain_domain
.domain_id
wheredomain_domain
.domain_id
is null anddomains
.deleted_at
is null)