Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 200
Anik Biswas Avatar asked Oct 12 '25 23:10

Anik Biswas


2 Answers

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');
});
like image 194
Jerodev Avatar answered Oct 14 '25 14:10

Jerodev


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')
like image 30
Martin Avatar answered Oct 14 '25 15:10

Martin