I am using laravel to develop my project.
In my controller I have Variable called $products
and i'm passing that variable to the view ,
return view('products.index')->with("products",$products);
No any issue till here !
Now i want to pass same $products
to the other view,
<a href="{!! route('productsnew.index') !!}"> Click Here </a>
How can i pass $products
with this route
?
Thanks For the Help !
CodePudding user response:
<a href="{{ route('productsnew.index', [ 'products' => $products->pluck('id') ]) }}">some link</a>
Route::get('/some/url/{product_ids}', function($product_ids) {
Product::whereIn('id', $product_ids)->get();
})->name('prodictsnew.index');
But you are much better off using a category id.
<a href="{{ route('category.index', [ 'category_id' => $category->id ]) }}">{{ $category->name }}</a>