使用多列的复杂 OrderBy

Complex OrderBy using multiple columns

我有一个足球赛事 table,它显示了基于 minuteextra_minute 的赛事。例如:

 id |    type    | minute | extra_minute  |  reason
 1  | yellowcard |   45   | null          |   null
 2  | yellowcard |   45   |  1            |   null
 3  |   period   |   45   | null          |    HT
 4  |    goal    |   45   |  2            |   null
 5  |    goal    |   46   |  2            |   null    // this is second half
 6  |   period   |   90   | null          |    FT
 7  |    goal    |   90   |  2            |   null

顺序应该是

yellowcard (45)
yellowcard (45+1)
   goal    (45+2)
    HT
   goal    (46)
   goal    (90+2)
    FT

我在 Match 中尝试了关系查询,例如

public function events() {
    return $this->hasMany(Event::class)->orderBy('minute', 'asc')
                                       ->orderBy('extra_minute', 'asc');
}

但这会导致

    HT
yellowcard (45)
yellowcard (45+1)
   goal    (45+2)
   ...

使用 Laravel 查询生成器对所需样式进行排序的方法是什么? 我知道为什么我的查询生成器不起作用,但我想不出一些东西来实现我想要的

->orderByRaw('type = ? asc', 'period') 是方法。

return $this->hasMany(Event::class)
            ->orderBy('minute', 'asc')
            ->orderByRaw('type = ? asc', 'period')
            ->orderBy('et_minute', 'asc');