Route :
Route::get('merchantTrans/{id}','MerchantController@merchant');
Merchant Controller :
public function merchant($id){
$merchant = Merchant::whereId($id)->get();
return redirect('Merchant view')->with(compact('merchant'));
}
View Route :
Route::view('Merchant view','merchant.listview')->name('Merchant view');
I cannot pass merchant compact value to view.
Produce error
Any other best way?
Try this
return redirect()->route('Merchant view')->with( ['merchant' => $merchant] );
In blade file :
<?php $merchants = Session::get('merchant'); ?>
{{ @foreach ($merchants as $merchant)
//your code
@endforeach }}
Hope it helps you !