{"id":11278,"date":"2020-02-27T10:08:21","date_gmt":"2020-02-27T10:08:21","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=11278"},"modified":"2021-11-12T06:48:05","modified_gmt":"2021-11-12T06:48:05","slug":"master-fixed-layout-in-laravel","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/master-fixed-layout-in-laravel\/","title":{"rendered":"Master\/fixed layout in Laravel."},"content":{"rendered":"\n<p><em>@yield(&#8220;Parameter&#8221;)<\/em> :- It is a&nbsp;<strong>section<\/strong>&nbsp;which requires to be filled in by your view which extends the layout. You could pass it a default value through the second parameter if you&#8217;d like. <\/p>\n\n\n\n<p><em>@section(&#8220;Parameter&#8221;)<\/em>:-  It is a&nbsp;<strong>section<\/strong>&nbsp;which is used to fill HTML content in view to extends the layout.<\/p>\n\n\n\n<p>Below example is master layout program, in which all content is fixed but title and body are dynamic which is extend by other view.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantSinghRajput03\/b66b16043ec76cc53d97fecf771e87fe.js\"><\/script>\n\n\n\n<p>Below program is <strong><em>product.blade.php<\/em><\/strong> page which extends master layout and assigns title and body as required.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"447\" height=\"190\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-page-fixed-layout.png\" alt=\"\" class=\"wp-image-11284\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-page-fixed-layout.png 447w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-page-fixed-layout-300x128.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/figure><\/div>\n\n\n\n<p>After that, we have to declare a function in the controller so that it returns the address of view. See below:-  <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"114\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-controller.png\" alt=\"\" class=\"wp-image-11308\"\/><\/figure><\/div>\n\n\n\n<p>After that, we have to route the controller and function into web.php. See the below image:- <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"364\" height=\"41\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-route.png\" alt=\"\" class=\"wp-image-11311\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-route.png 364w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-route-300x34.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-route-355x41.png 355w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/figure><\/div>\n\n\n\n<p>Now run the server and copy the address and add products in it and hit enter. See the output below:-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"309\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-output-fixed-layout-1024x309.png\" alt=\"\" class=\"wp-image-11314\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-output-fixed-layout-1024x309.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-output-fixed-layout-300x90.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-output-fixed-layout-768x231.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/product-output-fixed-layout.png 1092w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_32256\"><iframe loading=\"lazy\"  id=\"_ytid_85063\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_32256\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>@yield(&#8220;Parameter&#8221;) :- It is a&nbsp;section&nbsp;which requires to be filled in by your view which extends the layout. You could pass it a default value through the second parameter if you&#8217;d&#8230; <\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[5203],"class_list":["post-11278","post","type-post","status-publish","format-standard","hentry","category-laravel","tag-laravel"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=11278"}],"version-history":[{"count":23,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11278\/revisions"}],"predecessor-version":[{"id":24905,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11278\/revisions\/24905"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=11278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=11278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=11278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}