如何为 PHP Laravel 5 的子目录中的视图创建 View Composer

How to create View Composer for view in subdirectory in PHP Laravel 5

我正在尝试在 PHP Laravel 5 中创建一个 View Composer。我的模板布局是这样组织的

resources/
  views/
     layouts/
       master2.blade.php
     index.blade.php
     master1.blade.php

我已经通过调用

成功地为 master1 注册了作曲家
view()->composer('master1', function ($view) { });

但是,如何为 master2 创建一个?

我都试过了:

view()->composer('layouts.master1', function ($view) { });
view()->composer('layouts/master1', function ($view) { });

但其中 none 有效。

我明白了。以下语法有效:

view()->composer('layouts.master1', function ($view) { });

但首先我必须清除 artisan 缓存并在视图中进行编辑(例如插入 space):

php artisan clear-compiled
php artisan cache:clear