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