0
0
Laravelframework~10 mins

Including sub-views (@include) in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to include a sub-view named 'header' in a Blade template.

Laravel
@[1]('header')
Drag options to blanks, or click blank then click option'
Ainclude
Bextends
Csection
Dyield
Attempts:
3 left
💡 Hint
Common Mistakes
Using @extends instead of @include
Using @section or @yield which are for layouts and sections
2fill in blank
medium

Complete the code to include a sub-view named 'footer' passing a variable 'year' to it.

Laravel
@include('footer', ['[1]' => $year])
Drag options to blanks, or click blank then click option'
Adate
Btime
Cyear
Dfooter
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different key name than the variable expected in the sub-view
Passing the variable without an array
3fill in blank
hard

Fix the error in the code to correctly include a sub-view named 'nav' with a variable 'items'.

Laravel
@include('nav', [1])
Drag options to blanks, or click blank then click option'
Aitems => $items
Bitems
C$items
D['items' => $items]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the variable directly without array brackets
Using invalid syntax without quotes or brackets
4fill in blank
hard

Fill both blanks to include a sub-view named 'sidebar' and pass variables 'user' and 'role' to it.

Laravel
@include('[1]', ['[2]' => $user, 'role' => $role])
Drag options to blanks, or click blank then click option'
Asidebar
Bprofile
Cuser
Daccount
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sub-view name
Using wrong variable key name
5fill in blank
hard

Fill all three blanks to include a sub-view named 'card', passing variables 'title', 'content', and 'footer'.

Laravel
@include('[1]', ['[2]' => $title, '[3]' => $content, 'footer' => $footer])
Drag options to blanks, or click blank then click option'
Acard
Btitle
Ccontent
Dpanel
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sub-view name
Mismatching variable keys and variable names