I have Listings table with hasOne relationship to Listing_images table to get its first image. Listing Model
public function first_listing_image()
{
return $this->hasOne('App\Listing_image');
}
In controller
$listings = Listing::with('first_listing_image')->orderBy( ??? )->paginate(10);
I want to order the results by if there is an image on Listing_images table. So the listings with image will be at top of the list. How to achive this?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vDx6gA
via IFTTT
Aucun commentaire:
Enregistrer un commentaire