I have difficulties getting my head around laravels blade layouts.
All the examples and documentations around the internet (e.g. laravel documentation: https://laravel.com/docs/5.3/blade or video tutorials on youtube) only use one master.blade.php as layout.
Is there a best practice for more complex projects?
The following content types are included in my project:
All of these content types have different layouts:
So I don't know in what situation ...
... or ...
This one drives me crazy right now and I couldn't find anything valuable like a best practice wether to use layouts or not.
Thank you so much for your help!
A layout structure can easily become a mess, that is why it is heavily recommended to keep layouts and partials organized in an intuitive folder structure. By doing so, you will ensure that in the future, when your app grows, it will stay clean and organized. It also depends on which kind of project you are working on. Believe it or not, sometimes the folder structure varies from project to project.
As far as I know, there are not any "best practices" on how to organize a layout folder specific to Laravel, but here is an example of how I organize my projects (and has worked for all my Laravel apps out there):
views/
├── v1/
│ ├── master
| | ├── master-public.blade.php
| | ├── master-admin.blade.php
| | ├── master-user.blade.php
| ├── components
| │ ├── navigation
| | | ├── public.blade.php
| | | ├── admin.blade.php
| | | ├── user.blade.php
| | ├── headers
| | ├── footers
| ├── views
| | ├── home
| | ├── chat
| | ├── order
| | ├── reports
| ├── partials
| | ├── ads.blade.php
| | ├── sidebar.blade.php
| ├── public
| | ├── registration.blade.php
| | ├── login.blade.php
├── v2/
└── v2.2/
The most important thing to mention here is that inside my views directory I create a folder per each route I end up having in my app.
Also, I believe that it is important to have as parent folders the version of the UI of the webapp. Sometimes, when redoing the UI one tends to just save the files under the same directories, which is not good long-term since you will end up having a sea of files for different versions of your site in the same folder.
Hopefully this helps!
Cheers and good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With