2017-09-06 3 views
0

なぜ関係が接続されていないのかという問題に直面しています。RelationNotFoundException Laravel

class Internet extends Model 
{ 
    protected $with=['vendor','coba']; 
    public function vendor() 
    { 
     return $this->belongTo('App\Vendor'); 
    } 
} 

internets.php

class Vendor extends Model 
{ 
    public function internets() 
    { 
     return $this->hasMany('App\Internet'); 
    } 
} 

vendor.phpいずれかが私を助けることができますか?

+0

エラーが発生していますか? –

+0

DB構造を – bhill77

+0

に表示してください 'use App \ Internet;'および/または 'use App \ Vendor;' – Demonyowh

答えて

2

belongsToの

return $this->belongsTo('App\Vendor'); 
+0

私はすでに "s"を追加していますが、何もしません –

0

私は、これはヨーヨーを解決することを願っています。この

ベンダーで

class Vendor extends Model 
{ 
    protected $table = 'Vendor Table Name'; 
    protected $primarykey = 'Your Vendor Table primary Key'; 
    public function internets() 
    { 
     return $this->hasMany(App\Internet::class, 'relational key'); 
    } 
} 

し、インターネットで

class Internet extends Model 
{ 
    protected $with=['vendor','coba']; 
    protected $table = 'Internet Table Name'; 
    protected $primarykey = 'Internet table primary key'; 
    public function vendor() 
    { 
     return $this->belongsTo(App\Vendor::class, 'relation key'); 
    } 
} 

のようなものを試してみてくださいになりますあなたがこのトリックをするかどうか私に知らせてください。