Answer the question
In order to leave comments, you need to log in
Why doesn't "using('CustomPivot')" work in Laravel 5.6 model?
Hi all.
I want to link the Location model and Locationgroups (n:m) using the custom Pivot-Model LocationgroupLocation
Locationgroup-Model:
class Locationgroup extends Model
{
public function locations()
{
return $this->belongsToMany('App\Location\Models\Location')->using('App\Location\Models\LocationgroupLocation');
}
}
class LocationgroupLocation extends Pivot
{
protected $table = 'locationgroup_location';
public function location()
{
return $this->hasMany('App\Location\Models\Location');
}
public function locationgroup()
{
return $this->hasMany('App\Location\Models\Locationgroup');
}
}
$locationgroup->load('locations');
QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dev.location_locationgroup' doesn't exist
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question