Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $songs = DB::table('songs')
- ->join('song_user', 'songs.id', '=', 'song_user.song_id')
- ->where('song_user.user_id', '=', $user->id)
- ->orderBy("song_user.play_count", "desc")
- ->get();
- $songs = Song::
- with(array("song_user" => function($query) use ($user) {
- $query->where("user_id", "=", $user->id)->orderBy("play_count", "desc");
- }))
- public function songs() {
- return $this
- ->belongsToMany('Song')
- ->withPivot('play_count')
- ->orderBy('pivot_play_count', 'desc');
- }
- Jingle Bells: 5
- Mary had a little lamb: 10
- Soft Kitty: 20
- The Catalyst: 100
- The Catalyst: 100
- Soft Kitty: 20
- Mary had a little lamb: 10
- Jingle Bells: 5
- $songs = Song->join('song_user', 'songs.id', '=', 'song_user.song_id')
- ->where('song_user.user_id', '=', $user->id)
- ->orderBy("song_user.play_count", "desc")
- ->get();
- $article->tags()->order_by( 'order')->get();
- return $this->belongsToMany('AppPost')->withTimestamps()->orderByDesc('posts.created_at');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement