first Unknown column 'assignable_table.assignable_id'. does this column exist?
is model TeaserAssign using the table assignable_table
?
if yes then looks like your hasMany method is wrong ?
$this->hasMany('App\Models\TeaserAssign', 'id', 'local_key');
Assuming the relationship is setup correctly you can do a whereHas
to check for existence of a relationship with conditions.
public function scopeAssigned($query, $iAssignedId)
{
return $query->whereHas('assign', function ($q) use ($iAssignedId) {
$q->where('assignable_id', $iAssignedId);
});
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community