Laravel basic Database 'with' function

时间:2018-02-03 09:15:09

标签: php laravel

public function GetStock()

{
    $whatstock=stock::all() ;
    $max=stock::max('idStock') ;
    return view('welcome')->with('zzz',$max) 
                          ->with('any',$whatstock) ; 

i get it thankyou for answering :).

1 个答案:

答案 0 :(得分:1)

You can't return view twice, so change it it:

return view('welcome', ['zzz' => $max, 'any' => $whatstock]);

Or:

return view('welcome')->with('zzz', $max)->with('any', $whatstock);