0
如何适用于雄辩的查询与“hasOne”关联关系表排序?在Laravel使用排序查询口才
品牌型号
class Brand extends Eloquent
{
protected $table = 'brand';
protected $primaryKey = 'id';
protected $fillable = ['brand_name'];
public $sortable = ['brand_name'];
public function brandModel() {
return $this->hasOne('App\Brandmodel', 'brand_id')
->select('id', 'brand_id', 'brand_model_name');
}
}
---------------------------------------
class Brandmodel extends Eloquent
{
protected $table = 'brandmodel';
protected $primaryKey = 'id';
protected $fillable = ['brand_id'];
public $sortable = ['brand_model_name'];
}
在这种情况下,我们可以使用排序 “BRAND_NAME”。但是我不能够使用“brand_model_name”进行排序。
嗨,感谢您的回复,但我期待能用“充分雄辩” – Franklin
这只是使用Eloquent的查询生成器来加入表格,使用您设置的关系方法无法做到这一点。这是因为“Eloqent-LY”,你会得到它。 – Dwight