I have two models and need to pull both and filter the results based on some conditions
Mobile: id, name, make ...
Offer: id, modelid, retailerid...
my Models are set up like this:
// Mobile
public function offer()
{
return $this->hasMany('App/Offer','modelid','id');
}
// Offer
public function mobile()
{
return $this->belongsTo('App/Mobile','modelid');
}
when I run
$offers = App\Mobile::with(['offer'=>function($q){
$q->orderBy('phonecost','asc')->first();
}])->orderBy('Popularity','desc')->paginate(10);
I get an empty array in the offer relationship