Answer the question
In order to leave comments, you need to log in
In Laravel 5.7, how can I conveniently place all template files in a separate views subfolder?
Hello.
The bottom line is this:
I want to make the design of the project in the form of a separate "theme" (like in WordPress), so as not to overwrite the templates already created using, for example, make:auth, etc. templates, but simply make new ones in a separate folder.
make your implementation of ViewComposer on top of the existing one so that it automatically includes the theme you need in the path
You don't need to google anything, because it's unlikely that you'll find it. But you can try: "laravel ViewComposer override" or similar. Plain OOP + ioc laravel.but I'm new to Laravel, and it sounds like "avada kedavra" to me.
Auth::routes(['verify' => true]);
resources/views/auth
resources/views/mytheme/auth
Answer the question
In order to leave comments, you need to log in
The most primitive method is to simply substitute the
Controller prefix
private $viewPath = 'site';
//просто подставляешь
return view($this->viewPath . 'index');
'paths' => [
resource_path('views') . 'сюда свой путь',
],
Firstly, it must be said that this is rarely required on Laravel projects, it is still not cms, but if there is a serious redesign, then in any case, you will most likely not return to the old one. If you use git, you can always revert to the old design. But again, the design is changing and most likely some of the functionality will also change and this functionality will not be compatible with the old theme.
Secondly .. if you still need to do this (the only option when you really need to see something like this: one topic during the day, another at night. Something like that), just make the appropriate key in the config, in the base controller, from which all the rest are inherited make a view method, where you already define the full path to the theme view. Or you make a trait in which, again, you create such a method. That's actually all
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question