dpz90118 2017-04-18 05:35
浏览 81

Laravel 5.2 ajax分页显示错误“方法链接不存在”

Am stuck with a problem ,

when i run my code with pagination i am getting an error

" Error Exception in Macroable.php line 74: Method links does not exist. "

My controller code

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();  
        }

In view blade

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

After a lot of search, It says that use render() instead of links(),But i still face the error " ErrorException in Macroable.php line 74: Method render does not exist. "

when I dd($products) ,i get the result

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
    }

Please find me a solution

  • 写回答

1条回答 默认 最新

  • duanjian5059 2017-04-18 09:13
    关注

    Have you Go through this url for Ajax Pagination:- https://gist.github.com/tobysteward/6163902

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用