2017-04-18 116 views
0

我坚持着一个问题,Laravel 5.2 AJAX分页显示“不存在法通”错误

当我与分页我正在一个错误

“错误异常在Macroable.php线74运行我的代码:方法链接不存在。“

我的控制器代码

public function products(Request $request) 
{ 
    $products  = ProductLangModel::select('product.price','product.active','product_lang.*','product_image.image') 
              ->join('product','product.id','=','product_lang.id_product') 
              ->join('product_image','product_image.id_product','=','product_lang.id_product') 
              ->where('idlang',$lng) 
              ->paginate(4); 

if ($request->ajax()) { 

      return view('frontend.product.List_productAjax', ['products' => $products])->render(); 
     } 

鉴于刀片

         <nav class="woocommerce-pagination"> 
              <ul class="page-numbers"> 
               <li> 
                <span class="page-numbers">{{ $products->links() }}</span> 
               </li> 
              </ul> 
             </nav> 

很多搜​​索后,它说,使用render(),而不是链接(),但我仍然面对错误 “ErrorException在Macroable.php线74:方法确实呈现不存在。 “

当我DD($产品),我得到的结果

Collection {#475 ▼ 
    #items: array:10 [▼ 
    0 => ProductLangModel {#476 ▶} 
    1 => ProductLangModel {#477 ▶} 
    2 => ProductLangModel {#478 ▶} 
    3 => ProductLangModel {#479 ▶} 
    4 => ProductLangModel {#480 ▶} 
    5 => ProductLangModel {#481 ▶} 
    6 => ProductLangModel {#482 ▶} 
    7 => ProductLangModel {#483 ▶} 
    8 => ProductLangModel {#484 ▶} 
    9 => ProductLangModel {#485 ▶} 
    ] 
} 
    0 => ProductLangModel {#476 ▼ 
     #table: "product_lang" 
     +timestamps: false 
     #connection: null 
     #primaryKey: "id" 
     #keyType: "int" 
     #perPage: 15 
     +incrementing: true 
     #attributes: array:12 [▶] 
     #original: array:12 [▼ 
     "price" => "2.000" 
     "active" => 1 
     "id" => 3 
     "id_product" => 2 
     "idlang" => 1 
     "name" => "VIN-Billing Name" 
     "description_short" => "short desc_VIN-Billing Name" 
     "description" => "hgfdg" 
     "meta_title" => "fdgdfgd" 
     "meta_description" => "gfhfgh" 
     "meta_keywords" => "hfgh" 
     "image" => "1488180547.jpg" 
     ] 
     #relations: [] 
     #hidden: [] 
     #visible: [] 
     #appends: [] 
     #fillable: [] 
     #guarded: array:1 [▶] 
     #dates: [] 
     #dateFormat: null 
     #casts: [] 
     #touches: [] 
     #observables: [] 
     #with: [] 
     #morphClass: null 
     +exists: true 
     +wasRecentlyCreated: false 
    } 

请给我找一个解决方案

+0

试删除if($ request-> ajax),看看会发生什么 –

+0

如果我删除它,我的ajax分页将不起作用。 –

回答