モデル、データベース、コントローラーが別々のフォルダーにある 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: select
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)