先程Laravelでリレーションを実装する為Modelを変更しtinkerでテストをしたのですが、以下のエラーが発生しました。
Illuminate/Database/QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sample_db.points' doesn't exist (SQL: select * from `points` where `points`.`id` = 1 limit 1)'
Modelを調べるとファンクション名とエラーのテーブル名が同じだった為、ファンクション名を参照したいテーブル名に変更しました。
しかし、もう一度tinkerでテストしてもエラーが消えませんでした。キャッシュの削除も試したのですが変わりません。
このエラーはどうすれば解消できるのでしょうか。
変更したModelは以下になります。
php
1<?php 2 3namespace App; 4 5use Illuminate\Database\Eloquent\Model; 6 7class Customer extends Model 8{ 9 public function dtb_customer_point() 10 { 11 return $this->hasMany(Point::class); 12 } 13}
リレーションの子Modelは以下になります。
php
1<?php 2 3namespace App; 4 5use Illuminate\Database\Eloquent\Model; 6 7class Point extends Model 8{ 9 public function dtb_customer() 10 { 11 return $this->belongsTo(Customer::class); 12 } 13} 14
あなたの回答
tips
プレビュー