Can we extract an array in the laravel views?
for example consider this:
We've say 20 variables in a controller which we need to pass into blade, now of course we can pass these variables using compact like this:
return view('someview', compact('var_a', 'var_b', 'var_c', 'var_d' ....));
But is there way we can move all the variables in array and then pass it to blade and then somehow extract it in blade like this:
$data = array('var_a' => 'value', 'var_b' => 'value', 'var_c' => 'value', 'var_d' => 'value', );
return view('someview')->with($data);
then In blade access like this:
{{$var_a}} {{$var_b}} {{ $var_c}}
Like we have extract() function in PHP, which does the same, I'm just looking for same to use in blade
I don't wan't to access as index like this:
{{ $data['var_a'] }}
I've seen and inspired by similar syntax used in opencart