(10) Part-1 Master blade in Laravel | Master layout | Main layout for all pages

Опубликовано: 29 Сентябрь 2024
на канале: Career Development Lab
2,258
29

Master Layout:
The Blade Master Template is going to be your best friend. In the last episode we started to work with rendering views in Laravel. Recall, this amounts to doing something like return view('file'), where file is the name of the view we want to render. In this episode we’ll take a look at the concept of using a master template to act as the blueprint for our views. It is a fantastic way to reuse code and almost works in a similar way to the idea of having a class you can extend. The master template is the class, and the individual view files extend the master to allow for easy code reuse. Let’s take a look at how to do this now.

Create The Master Page
The Blade Master Template is where we can place all the boilerplate that all pages will typically make use of. Most times you can name this file something like master.blade.php. All view files that you would like to have made use of your master page can now use the @extends keyword to do so. Since our master page has the name of master.blade.php, in our view files we will use @extends('master').

Laravel series goal
My goal with this Laravel series is to create a guide for those just learning Laravel. This guide will take you from the very beginning of an idea into a real deployable application.

If you are facing any problem during development, you can post your queries free of cost at https://solutions.cdlcell.com so our team will respond to you within 24 hours.

If you need paid help from us, please visit https://solutions.cdlcell.com/user/in... to process a contract with us.

* Contact us: [email protected]
* Our website: https://cdlcell.com

* My Twitter:   / hadayatniazi3  
* My FB:   / hadayatniaziofficial  

Follow us on LinkedIn:   / cdlcell  
Follow us on Tiktok:   / cdlcell  
Join us on Instagram:   / cdlcell  
Follow us on Facebook:   / cdlcellpk  

Join our Laravel Developers whatsapp group: https://chat.whatsapp.com/JSA8qZZGVbP...

#php
#phplaravel
#laravel
#webdevelopment
#cdl
#career_development_lab
#hadayatniazi
#coding
#technology