how to pass many controller variables to the view in the Laravel

Asked

Viewed 546 times

0

I want to pass these variables, but it seems that quantity prevents me, there is another way?

        return view('pontuacao')->with('somas', $somas[0]->p)->with('somas1', $somas1[0]->s)->with('palpites', $palpites)->with('confrontos', $confrontos)->with('ranking', $ranking)->with('somas2', $somas2[0]->s)->with('somas3', $somas3[0]->s)->with('somas4', $somas4[0]->s)->with('somas5', $somas5[0]->s)->with('somas6', $somas6[0]->s);

1 answer

0


You can put all data in 1 array and return the array:

$data = array( 'sums' => $sums[0]->p, 'somas1' => $somas1[0]->s, '...' => '...' ); Return view('score')->with('data', $data);

or, passes variable by variable outside the with():

Return view('score',['sums' => $sums[0]->p, 'somas1' => $somas1[0]->s, '...' => '...']);

test there and return what you have chosen! :D

Salve of Zoyo!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.