Laravelで顧客情報テーブルと顧客ポイントテーブルのリレーションを作成したいのですが、Modelが参照するテーブル名が間違っているらしく、以下のエラーが表示されます。
error
1Illuminate/Database/QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'eccube_db.customers' doesn't exist (SQL: select * from `customers` where `customers`.`id` = 12 limit 1)'
複数テーブルを定義したいときのテーブル名は何処で指定すればいいのでしょうか。
定義したModelは以下になります。
Customer.php
php
1<?php 2 3namespace App; 4 5use Illuminate\Database\Eloquent\Model; 6 7class Customer extends Model 8{ 9 public function point() 10 { 11 return $this->hasone('App\Point'); 12 } 13}
Point.php
php
1<?php 2 3namespace App; 4 5use Illuminate\Database\Eloquent\Model; 6 7class Point extends Model 8{ 9 protected $primaryKey = "customer_id"; 10 11 public function customer() 12 { 13 return $this->belongto('App\Customer'); 14 } 15}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。