as I said in the title, I would like to get all assigned variables in a template using Blade with laravel 5.1
Example :
Controller :
class Ctrl extends Controller
{
public function index() {
$title = "i'm a title";
$name = "i'm a name";
return view('myview', compact('title', 'name'));
}
}
Template : myview.blade.php
@getVars()
Service provider :
class getVarsServiceProvider extends ServiceProvider {
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
Blade::directive('getVars', function() {
// MUST return array('title' => "i'm a title", "name" => "i'm a name");
return "all vars"; // <----
});
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}