Update your AppServiceProvider by adding a view composer to the boot method and using '*' to share it with all views:
<?php
namespace AppProviders;
use IlluminateSupportServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
view()->composer('*', function($view){
$view_name = str_replace('.', '-', $view->getName());
view()->share('view_name', $view_name);
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
{{$view_name}}
will be made available to your blade templates.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…