How to change the name of the default theme to everything in laravel

I am new to laravel in my public / themes folder. I have two default themes and orange. I want to go with orange, but I don’t see where the default keyword is indicated. I am trying to change this in ThemeviewFinder.php, but it only affects the views, not the assets. Please help me

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');
}
+4
source share
1 answer

I was able to achieve this using special middleware. In my case, I had to display another template / theme based on the domain name.

TemplateMiddleware.php

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);
}

Kernel.php

protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \App\Http\Middleware\TemplateMiddleware::class,
];
0
source

All Articles