Route::get('/',function (){
$collection = collect(['product'=>'chair','price'=>100]);
//dd($collection);
return view('welcome')-with('prices',$collection);
});
I want to pass $collection on view but I get this error:
Type error: Argument 2 passed to with() must be callable or null,
object given
and I don't understand why.
Can somebody explain me?
使用->with
而不是-with
:
return view('welcome')->with('prices',$collection);
Try this
$page_data = array(
'product'=>'chair',
'price'=>100
);
return \View::make('welcome', $page_data);
or
return view('welcome', $page_data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.