2
我的下一个问题是订购具有许多关系和排序字段在关系中的项目。Laravel orderBy has许多关系
我有表:国家,它只有ID字段 我也表:country_translation,其中有列:名称,郎
在我CountryController在索引() - 方法我想告诉所有默认语言的国家通过参数名称对它们进行排序并对它们进行分页。
这是我的国家型号:
class Country extends Model {
protected $fillable = [
'code', 'latitude', 'longitude', 'currency_id', 'timezone', 'dam_date', 'status',
];
public function translations() {
return $this->hasMany('App\Models\CountryTranslation');
}
}
CountryTranslation型号:
class CountryTranslation extends Model {
protected $fillable = [
'name', 'lang', 'country_id',
];
public function country() {
return $this->hasOne('Country');
}
}
再次谢谢:) –