Laravel Eloquent Relations: ->latest()

前端 未结 3 350
轻奢々
轻奢々 2020-12-15 16:23

What is the function of latest() in laravel?

Example:

public function activity()
{
    return $this->hasMany(\'App\\Activity\')
        ->with(         


        
3条回答
  •  轮回少年
    2020-12-15 17:06

    ->latest() fetches the most recent set of data from the Database. In short, it sorts the data fetched, using the 'created_at' column to chronologically order the data.

提交回复
热议问题