Anik Biswas
Anik Biswas

Reputation: 135

laravel @include not working

I am trying to include files in my user page using blade syntax

@include('header')

@yield('content')

@include('footer')

https://i.sstatic.net/7Ulsz.png

here is web.php

Route::get('/', function () {
    return view('layouts.user');
});

i'm getting this error

(1/1) InvalidArgumentException View [layouts.user] not found.

Upvotes: 4

Views: 13234

Answers (2)

Jerodev
Jerodev

Reputation: 33216

You always have to use the absolute path to a view. So in your case, this should be:

@include('user.layouts.header')

@yield('content')

@include('user.layouts.footer')

The same counts for your routes file:

Route::get('/', function () {
    return view('user.layouts.user');
});

Upvotes: 6

Martin
Martin

Reputation: 1279

It's because you should include full path from the view folder so it will look like this:

@include('user.layouts.header')

@include('user.layouts.footer')

Upvotes: 2

Related Questions