2
votes

I'm using the modular structure as described in the blog below with Laravel 5.1 http://ziyahanalbeniz.blogspot.com.tr/2015/03/modular-structure-in-laravel-5.html

In fact I have a module user which has the following structure:

- Controllers

- Models

- Translations

- Views
-> index.blade.php
-> register.blade.php

In my Views directory I have a index.blade.php file and a register.blade.php file. In my index.blade.php file I use: @include('register') in order to include the register file within my index php file. But I get a view not found exception when calling my index file.

I have some trouble which is the correct path I have to add within my @include. @include('user.register') doesn't work neither. Any ideas? Thank you

1

1 Answers

1
votes

You should include the path relative to resources/view (no matter where you calling from), replacing "/"s by "."s.

For example:

yourproject/resources/views/template.php
yourproject/resources/views/module1/main.php
yourproject/resources/views/module1/foo.php
yourproject/resources/views/module2/main.php
yourproject/resources/views/module2/bar.php

Should be included as:

@include('template');
@include('module1.main');
@include('module1.foo');
@include('module2.main');
@include('module2.bar');

Remember that when you use @include, it does a literal copy of the file, as if you copied and pasted it. @include DOES NOT extends the file, so you can't replace @yield or @section tags when you use it.

In other words, the calling file becomes a parent. If you want to build a child view, you should use @extends instead.

Cheers