I am unable to solve passing of array issue
below is my function in controller
public function fetchData($id) { $id=base64_decode(urldecode($id)); prod_detail=ProductDetail::select('prod_id','supplier_id','price','open_stock','discount_rate','min_order_level')->where('prod_id','=',$id)->get(); return redirect()->route('prod_d_view', compact($prod_detail)); }
below is my route
Route::get('/product_view', function(){ return view('/admin/product_d_mgt'); })->name('prod_d_view');
below is my error
Undefined variable: prod_detail (View: adminproduct_d_mgt.blade.php)
I am unable to pass the full array from one controller using redirect()->route() to another view
Advertisement
Answer
Maybe you can use something like this:
In your controller function:
... return Redirect::to('product_view')->with('prod_detail', $prod_detail);
And in your product_view.blade.php file (in resources/view directory):
@if(Session::has('prod_detail')) @foreach (Session::get('prod_detail')as $key => $value) {{ $value->ColumnName }} {{ $value->ColumnName2 }} @endforeach @endif