i would like to pass an array as parameter from my controller to the blade template.
My controller looks like this:
$myArray = array('data' => 'data');
return View::make('myTableIndex')
->nest('myTable', 'my_table_template', $myArray)
In my blade template i've got a yield like this:
@yield('myTable', $myArray)
But i've get the error:
Error: Array to string conversion
That's because the yield function only accepts strings, right?
Background is: I want a table template which i can use dynamically for multiple purpose or multiple data, so i can use the same template for multiple tables and just pass the columns and content as array.
How can i pass an array to my yield section?
section
instead? – Liquefysection
in a separate file andinclude
it. – Liquefy@include('viewname', 'variablename')
so you can use variable name like$variablename
in your includedview
. – Liquefy@include('view.name', ['varname' => $array])
. – Liquefy