On July 8, 2020 . By CodimTh Category: Web Laravel Code snippet that can be used to use OrderBy on Eloquent relationships in Laravel 7. public function posts() { return $this->hasMany(Post::class); } public function postsByTitle() { return $this->hasMany(Post::class)->orderBy('title'); } Tags : Laravel Laravel tutoriel Previous PostForeign keys with migrations: don’t forget UNSIGNED in Laravel 7Next PostCreate a custom bulk node action in Drupal 8 & 9 Comments Add new comment Your name Subject Comment About text formats Restricted HTML Leave this field blank
Comments