Adding sub view in Laravel

If you want to include a sub-view in the blade template you can include it by using @include(‘view.name’). The dot is used as folder separator.

return View::make('user.details', array('id' => $id));

In the example above it points to the app/views/auth/details.blade.php

To include a sub view do the below code.

file: Subview.blade.php

<html>

  <html stuff>

  @yield('content')

</html>

file: hello.blade.php

@extends('Subview')

 

@section('content')

  <html stuff>

@stop

Another way or the latest way is given below.

@include(‘view.name’)

The view.name should be in your main views folder.

In Laravel 4 versions

app/views/view/name.blade.php  

Laravel 5 versions

resources/views/view/name.blade.php

If you want to pass parameters to view you can use an array to pass it.

@include('view.name', array('paramName' => 'value'))

Then use the value in the view.

<p>{{$paramName}}</p>