Laravel storing multiple folders of config, views, css and js in a root folder outside of the resources folder

Viewed 212

Just wondering if there is a way to store folders full of views, css, js and a config file outside of the resources folder. So basically the site im working on has a login portal that redirects to a subdomain. ive achieved this but now the issue is that the boss wants each subdomain to pull in separate views, etc from a folder in the root directory rather than having multiple folders in multiple locations in the resources folder. The target is to basically package up each site into its own folder.

. app/
    .resources/
    .sites (new) /
        .site one (new) /
             . views (new) /
             . css (new) /
        .site two (new) /
             .views (new) /
             . css (new) /

Is there anyway to achieve this?

1 Answers

Yes you can absolutely change the location of your views, go to your config/views.php and change it to what you need:

    <?php

    return [
    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */

        'paths' => [
            resource_path('views'), // This is the default path
            app_path('sites.site_one'),
            app_path('sites.site_two'),
            app_path('sites.site_three'),
        ],

        ...
    ]

As for your CSS, you can still keep that in the same folder paths, but you will need to change the location in the webpack.mix.js file.

Related