Answer the question
In order to leave comments, you need to log in
Why is selection not working in laravel?
The News entity has a source_id field (owned by companies)
In Company
public function news()
{
return $this->hasMany('App\News', 'source_id', 'id');
}
Answer the question
In order to leave comments, you need to log in
What is App\CustomCollection\SupportsCollection?
Direct text is written that the wrong type of a collection is transferred.
What is App\CustomCollection\SupportsCollection and where does it come from?
First of all, they most likely mixed up the order of the passed parameters: the
first is foreign_key, the second is local_key.
Secondly, they could also confuse entities, judging by your words.
class News
public function company()
{
return $this->hasMany('App\Company', 'id', 'source_id');
}
class Company
public function news()
{
return $this->belongsTo('App\News');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question