2017-04-11 57 views

回答

0

如果你看看到findWhere()方法,你會看到,它執行查詢:

$model = $this->model->get($columns); 

所以,你不能使用orderBy()paginate()findWhere()之後。

+0

我嘗試使用,其中這樣的:'公共功能的GetList($年) { $查詢=父::在哪裏( '年',「= 」,$年) - >排序依據( '的updated_at') - > PAGINATE(10); return $ query; }'。但存在錯誤:'調用未定義的方法InfyOm \發電機\ COMMON \ BaseRepository ::其中()' –

+0

@samueltoh,因爲這個包沒有'其中()'方法(檢查文檔)。 –

+0

是的,它不存在。那麼,我該如何解決我的問題?如果沒有其他方法? –

0

findWhere執行的是查詢和使用get得到你的價值()。

嘗試改變你的代碼如下:

public function getList($year) 
{ 
    $query = parent::where('year', '=>', $year) 
      ->orderBy('updated_at') 
      ->paginate(10); 
    return $query; 
} 
+0

存在着錯誤:'調用未定義的方法InfyOm \發電機\ COMMON \ BaseRepository ::其中()' –

+0

您可以檢查此https://github.com/infyomlabs 這https://github.com/andersao/ L5-庫/斑點/主/ SRC/Prettus /存儲庫/鋒/ BaseRepository.php –

相關問題