根据我的域名,我需要分离视图文件夹

时间:2018-12-21 09:42:24

标签: laravel-5

基于我的域名,我需要分离视图文件夹,所以我已经在中间件中创建了ModifyViewFolder类文件,并在kernel.php中注册了它,但是它不能正常工作,不知道如何检查工作情况。也请验证我的kernel.php文件不知道是否正确注册。

文件路径:'View'=> \ App \ Http \ Middleware \ ModifyViewFolder :: class

use Closure;
use Illuminate\View\FileViewFinder;
use Illuminate\Support\Facades\View;

class ModifyViewFolder
{

  public function handle($request, Closure $next)
  {
      $finder = new FileViewFinder(app()['files'], [
        app_path('../resources/views/' . $request->server->get('HTTP_HOST')),
        app_path('../resources/views/'),

      ]);
      View::setFinder($finder);

      return $next($request);
  }

}

kernel.php:App \ Http \ kernel.php

受保护的$ routeMiddleware = [

    'View'=> \App\Http\Middleware\ModifyViewFolder::class,
     ];

1 个答案:

答案 0 :(得分:2)

请在下面尝试。请在$ middleware中分配路径。

    ProductName SaleTypeName
0      Bircher          NaN
1        Salad        valid
2        Carac          NaN
3        Salad        valid
4      Bircher          NaN
5        Carac          NaN
6        Carac          NaN
7        Salad        valid
8      Bircher          NaN
9        Carac          NaN
10       Carac          NaN
11       Salad        valid