I, answering my question, just to help.
class User extends Model implements ... { public function posts(){ return $this->hasMany('App\Post'); } public function recentPosts($limit = 5){ return $this->posts ->sortByDesc(function($post){ return $post->created_at; })->take($limit); } }
Tarek Adam Oct 24 '15 at 17:54 2015-10-24 17:54
source share