不幸的是,我在「評論,遊戲和信息」表之間創建了一個關係,但主表是Games,他命令我所有的遊戲,而我想訂購「審查」表的ID。OrderBy之後HasMany和屬於的關係
Models: Review
public function games()
{
return $this->hasMany('App\Models\Giochi', 'id_gioco', 'id');
}
Models: Giochi
public function review()
{
return $this->belongsTo('App\Models\Review', 'id', 'id_gioco');
}
public function infogiochi()
{
return $this->belongsTo('App\Models\InfoGiochi', 'id', 'id_gioco');
}
Models: InfoGiochi
public function games()
{
return $this->hasMany('App\Models\Giochi', 'id', 'id_gioco');
}
Controller:
$review = Giochi::with('Review','InfoGiochi')->orderBy('id','DESC')->get();
這裏是我的JSON的截圖:
如何訂購審查表ID的內容?
我把'$返回這 - >屬於關聯( '應用程序\ \型號審查', '身份證', 'id_gioco' ) - > orderBy('id','DESC')'但它不起作用... – LegoLiam