Php OrderBy基于Laravel中的列值?

Php OrderBy基于Laravel中的列值?,php,laravel,Php,Laravel,到目前为止,我的查询工作正常 但我需要添加另一个名为reseller\u type 分销商类型有3种不同的类型 VALUE | DEFINITION 0 = NONE 1 = Resale 2 = Resale : Show to first 3 = Resale : Show to last 如果分销商类型的值为0,则表示无 如果经销商类型的值为1表示,则记录为仅简单转售 如果

到目前为止,我的查询工作正常

但我需要添加另一个名为
reseller\u type

分销商类型有3种不同的类型

VALUE    |    DEFINITION
0        =       NONE
1        =       Resale
2        =       Resale : Show to first
3        =       Resale : Show to last
如果分销商类型的值为0,则表示无

如果经销商类型的值为1表示,则记录为
仅简单转售

如果“分销商类型”的值为2表示,则记录为“转售”,但需要首先显示

如果“分销商类型”的值为3,则记录为“转售”,但需要显示到最后一次

现在在我的查询中,我试图显示,如果分销商类型的记录的值为2,那么它将首先显示在其他记录之前,但如果值为3,它将仅自动显示在最后一个记录中

这是我的查询代码

          $base_query = DB::table('yeast_module')
            ->select('yeast_module.id','yeast_module.part_number','yeast_module.part_name','yeast_module.category',
            'yeast_module.description','yeast_module.spec_sheet','yeast_module.yeast_category',
            'yeast_module.optimum_fermentation_temp_f_low',
            'yeast_module.optimum_fermentation_temp_f_high',
            'yeast_module.optimum_fermentation_temp_c_low',
            'yeast_module.optimum_fermentation_temp_c_high',
            'yeast_module.alcohol_tolerance','yeast_module.packaging',

            'yeast_module.organic',
            'yeast_module.reseller_type',
            'yeast_module.flocculation',
            'yeast_module.attenuation_low_end',
            'yeast_module.attenuation_high_end',
            'yeast_module.sta1qc',
            'yeast_module.style_recommendation',
            'yeast_module.beer_style',
            'yeast_module.search_tags',


            'yeast_module.photo','yeast_module.deleted','yeast_module.created_at','yeast_module.updated_at',
            'yeast_category.category_desc')
            ->join('yeast_category','yeast_category.id','=','yeast_module.category')
            ->where(['yeast_module.deleted' => 0])
            ->where(['yeast_category.deleted' => 0])
            ->where(['yeast_module.category' => $id]);


          $data = $base_query->groupBy('yeast_module.id')->paginate(20);
          return $data;

一个选项是根据自定义列表进行排序。您可以在MySQL中使用
FIELD()。在laravel中,您可以执行以下操作:

$base_query->orderByRaw('FIELD(reseller_type, 2,1,0,3)');

转销商类型的查询在哪里?
?尚未编写,只是尝试执行。