Support the ongoing development of Laravel.io →
posted 10 years ago
Views
Last updated 1 year ago.
0

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

Last updated 1 year ago.
0

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 );
Last updated 1 year ago.
0

also know that you can chainable it

return View::make( 'viewfile', $data )
    ->with( 'data', $data )
    ->with( 'moreData', $moreData )
    ->with( 'msg', 'hola amigo' );
Last updated 1 year ago.
0

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

Last updated 1 year ago.
0

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 -

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.