with this approach
View::make('hello', $data);
every index in ```$data```` array will be become a variable, for example if
$data = [ 'msg' => 'hello world!' ];
return View::make( 'viewfile', $data );
then in your viewfile, you will got a variable called $msg
I recommend to you, use the with
function instead of passing an array directly to the make
function
try this
return View::make( 'viewfile', $data )->with( 'data', $data );
now in your view, there will a variable called $data
available to use
Thanks alot;
I can even remove the first $data from this code:
return View::make( 'viewfile', $data )->with( 'data', $data );
Becomes
return View::make( 'viewfile' )->with( 'data', $data );
also know that you can chainable it
return View::make( 'viewfile', $data )
->with( 'data', $data )
->with( 'moreData', $moreData )
->with( 'msg', 'hola amigo' );
arcollector said:
also know that you can chainable it
return View::make( 'viewfile', $data ) ->with( 'data', $data ) ->with( 'moreData', $moreData ) ->with( 'msg', 'hola amigo' );
Lovey thank you
Hello,
Where might I find documentation or more of an explanation of the "with" function? Is this part of Eloquent?
Thanks so much for any assistance you can provide -
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community