Laravel 5 get view name
Update your AppServiceProvider by adding a view composer to the boot method and using '*' to share it with all views:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
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.