Skip to content

Instantly share code, notes, and snippets.

@aranw
Created February 20, 2013 12:08
Show Gist options
  • Save aranw/4995084 to your computer and use it in GitHub Desktop.
Save aranw/4995084 to your computer and use it in GitHub Desktop.
<?php
$posts = DB::table('posts')
->join('image_post', 'posts.id', '=', 'image_post.post_id')
->join('images', 'image_post.image_id', '=', 'images.id')
->join('artist_post', 'posts.id', '=', 'artist_post.post_id')
->join('artists', 'artist_post.artist_id', '=', 'artists.id')
->where('posts.category', '!=', 'news')
->where('posts.status', '=', 'published')
->order_by('posts.created_at', 'desc')
->distinct()
->paginate($per_page, array('posts.id', 'artists.name', 'artists.forename', 'artists.surname', 'posts.title', 'posts.slug', 'posts.category', 'posts.created_at', 'images.saved_to', 'images.filename'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment