Laravel Serviceprovider $ this-> loadViewsFrom不会从包中加载刀片视图

时间:2018-01-26 07:46:50

标签: laravel-5

我正在创建一个File Contents包,初学者 通过Composer我已将我的包添加到测试应用程序中。

测试应用程序输出应该是Composer,而是打印视图名称

有什么问题?

DownloadsServiceProvider:

12345

控制器:

class DownloadsServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->loadViewsFrom(__DIR__.'/resources/views/download', 'downloads');

    public function register()
    {
        new Routes();
    }

}

路线:

namespace xxx\xxx\downloads;

use Illuminate\Http\Request;

class DownloadsController
{
    public function index(Request $request)
    {
        $test='12345';
        return View('downloads::test' ,compact('test'));
    }
}

查看:

public function registerRoutes()
{
    Route::prefix(self::CMSURL)->group(function () {

        Route::get(
            '/downloads',
            function (Request $request) {
                //return (new DownloadsController())->index($request)->name(self::DOWNLOADS_LISTER);
                return (new DownloadsController())->index($request);
            }
        );

    });
}

输出源:

{{$test}}
12345

0 个答案:

没有答案