1class User extends Authenticable {2 // Get most popular post of user3 public function mostPopularPost() {4 return $this->hasOne(Post::class)->ofMany('like_count', 'max');5 }6}
Tip given by @LaravelEloquent
1class User extends Authenticable {2 // Get most popular post of user3 public function mostPopularPost() {4 return $this->hasOne(Post::class)->ofMany('like_count', 'max');5 }6}
Tip given by @LaravelEloquent