Home > OS >  Laravel @extends second parameter array explanation
Laravel @extends second parameter array explanation

Time:03-08

Question: I am new to laravel,

@extends('layouts.app', ['page' => 'Receipts', 'pageSlug' => 'receipts', 'section' => 'inventory']) I understand @extends first parameter 'layouts.app', but what does the second parameter do?

CodePudding user response:

In Laravel @extend second parameter just to pass data in another blade.

@extends('layouts.app', ['title' => 'Page Title'])

This is how the second parameter works in laravel main layout

 <title>App Name - {{ ucfirst($title) }}</title>

CodePudding user response:

Since you are extending layouts.blade.php file, you have to look into the file. In layouts.blade.php you need variables such as $page, $pageSlug, $section to be defined. So you are defining/passing each variable.

Like Python page = Receipts, pageSlug = receipts, section = inventory

equals

'page' => 'Receipts', 'pageSlug' => 'receipts', 'section' => 'inventory'

  • Related