Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在laravel中将主题名称从默认更改为任意名称_Php_Laravel_Themes - Fatal编程技术网

Php 如何在laravel中将主题名称从默认更改为任意名称

Php 如何在laravel中将主题名称从默认更改为任意名称,php,laravel,themes,Php,Laravel,Themes,我是laravel的新手,在我的public/themes文件夹中,我有两个主题名为default和orange,我想使用orange,但我看不到在哪里指定了default关键字。我试图在eviewfinder.php中对此进行更改,但这只会影响视图,而不会影响资产。请帮帮我 public function setActiveTheme($theme) { $users = DB::table('config') ->select('activatedT

我是laravel的新手,在我的public/themes文件夹中,我有两个主题名为default和orange,我想使用orange,但我看不到在哪里指定了default关键字。我试图在eviewfinder.php中对此进行更改,但这只会影响视图,而不会影响资产。请帮帮我

public function setActiveTheme($theme)
{

$users = DB::table('config')
                 ->select('activatedTheme')
                 ->where('id', 1)
                 ->get();
    //print_r($users);
    foreach($users as $row){
        $theme = $row->activatedTheme;

    }
   $this->activeTheme = $theme;
    array_unshift($this->paths, $this->basePath.'/'.$theme.'/views');
}

我能够使用自定义中间件实现这一点。在我的用例中,我需要根据域名显示不同的模板/主题

TemplateMiddleware.php

Kernel.php


到目前为止你有试过什么吗?你试过的代码应该出现在你的问题中。我有added@J.ChomelShare视图中的“全局”变量与view::share('assets_path',app('assets_path');包含主题路径,可以在BaseController的_构造方法中声明。
public function handle($request, Closure $next)
{
    $paths = [];
    $app = app();

    /*
     *  Pull our template from our site name
     */
    $template = Template::where('domain', Request::server('SERVER_NAME'))->first();
    if($template)
    {
        $paths = [
            $app['config']['view.paths.templates'] . DIRECTORY_SEPARATOR . $template->tag
        ];
    }


    /*
     *  Default view path is ALWAYS last
     */
    $paths[] = $app['config']['view.paths.default'];

    /*
     * Overwrite the view finder paths
     */
    $finder = new FileViewFinder(app()['files'], $paths);
    View::setFinder($finder);

    return $next($request);
}
protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \App\Http\Middleware\TemplateMiddleware::class,
];