Level 29
Add the props to layouts, check the docs for more info https://laravel.com/docs/10.x/blade#passing-data-to-components
<x-app::layouts :has_header="$has_header" :has_footer="$has_footer">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
trying to load blade components when @props variable is true or false but doesn't seems to be working.
app.blade.php layout file
@props([
'has_header' => true,
'has_footer' => true,
])
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<link rel="stylesheet" href="{{ page_asset('css/app.css') }}">
</head>
<body class="font-sans antialiased">
<div id="app">
@if ($has_header)
<x-app::layouts.header />
@endif
{{ $slot }}
@if ($has_footer)
<x-app::layouts.footer />
@endif
</div>
</body>
</html>
login.blade.php
@props([
'has_header' => false,
'has_footer' => false,
])
<x-app::layouts>
// content
</x-app::layouts>
header and footer keeps showing on login page. is there a way to correctly implement this to have certain anonymous components load when @props is set to true or false?
Add the props to layouts, check the docs for more info https://laravel.com/docs/10.x/blade#passing-data-to-components
<x-app::layouts :has_header="$has_header" :has_footer="$has_footer">
Please or to participate in this conversation.