dongyan5239
2017-02-22 04:44
浏览 226
已采纳

Laravel抛出:方法paginate不存在错误

I am trying to use pagination in laravel. so i try to retrieve all the transactions and paginate it. my flow goes like this for your reference view->controller->repository->model .

myrepository:

public function getall(){

    $this->transaction = Transaction::all();


    return $this->transaction;

}

mycontroller:

 public function getall(){   
  $transactions = $this->transaction->getall()->paginate(10);

    //dd($this->transaction);



    return view('transactions', ['transactions' => $transactions]);

}

in my app.php under service providers i made sure i have pagination: Illuminate\Pagination\PaginationServiceProvider::class,

but there is no aliases though. so in my controller i did : use Illuminate\Pagination;

图片转代码服务由CSDN问答提供 功能建议

我试图在laravel中使用分页。 所以我尝试检索所有的交易并对其进行分页。 我的流程如下所示,用于您的参考视图 - > controller-> repository-> model。

myrepository:

  public  function getall(){
 
 $ this-> transaction = Transaction :: all(); 
 
 
返回$ this-> transaction; 
 
} 
   
 
 

mycontroller:

  public function getall(){
 $ transactions = $ this-> transaction-> getall() - &gt  ; paginate(10); 
 
 // dd($ this-> transaction); 
 
 
 
返回视图('transactions',['transactions'=> $ transactions]); \  n 
} 
   
 
 

在我的app.php服务提供商下我确定我有分页:Illuminate \ Pagination \ PaginationServiceProvider :: class, \ n

但是没有别名。 在我的控制器中我做了:使用Illuminate \ Pagination;

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题