Reputation: 53
I'm facing a problem, as to why the relation is not getting connected.
vendor.php
class Vendor extends Model
{
public function internets()
{
return $this->hasMany('App\Internet');
}
}
internets.php
class Internet extends Model
{
protected $with=['vendor','coba'];
public function vendor()
{
return $this->belongTo('App\Vendor');
}
}
any one can help me?
Upvotes: 0
Views: 488
Reputation: 75
Try something like this
In your vendor
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');
}
}
And In your internet
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');
}
}
I hope this will solve your problem let me know if this do the trick
Upvotes: 0