Laravel Load multiple views in same controller

Today, We want to share with you Laravel Load multiple views in same controller.In this post we will show you Different Views use same Controller Function, hear for laravel return multiple views from controller we will give you demo and example for implement.In this post, we will learn about how to pass data from one view to another view in laravel with an example.

Laravel Load multiple views in same controller

There are the Following The simple About Sharing Data Between Views Using Laravel View Composers Full Information With Example and source code.

As I will cover this Post with live Working example to develop sharing data with all views laravel, so the laravel view composer undefined variable is used for this example is following below.

Laravel Controller

Laravel nest load multiple view in a single function

return View::make('user_header_template', $member)
->nest('user_left_content_view', $profile)
->nest('user_main_content_view', $orders)
->nest('user_right_content_view', $products)
->nest('user_mobileter_template', $info);

Passing Data To Multiple Views : app/Http/Controllers/DspController.php

class DspController extends Controller
{

    public function mobile()
    {
        return view('mobile', [
            'key' => 'Mike McCarthy'
        ]);
    }

    public function update()
    {
        $key = 'Reynhard Sinaga';
        return view('mobile', compact('key'));
    }

    public function store()
    {
        return view('mobile')->with(
            'key',
            'Puerto Rico earthquake.'
        );
    }
}

Laravel Blade Views File

<nav class="navbar navbar-inverse">
        <div class="container-fluid">

            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/">Movie Maniac</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="mobile">Mobile</a></li>
                    <li><a href="store">Store</a></li>
                    <li><a href="update">Update</a></li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">latest movie title here</a></li>
                </ul>

            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>

app/Http/routes.php

Route::get('/', '[email protected]');
Route::get('/mobile', '[email protected]');
Route::get('/store', '[email protected]');
Route::get('/update', '[email protected]');

app/Http/Controllers/DspController.php

 /**
     * Return a list of the latest movies to the
     * homepage
     *
     * @return View
     */
    public function index()
    {
        $trandList = [
            'The Bachelor',
            'bachelor 2020',
            'reality steve bachelor peter weber',
            'the bachelor season 24 episode 1',
            'who does peter pick on the bachelor',
        ];

        return view('welcome', compact('trandList'));
    }

resources/views/welcome.blade.php

@extends('app')

@section('content')
        <h1>Latest The Bachelor 2020 - Reality Steve</h1>
        <p>Hannah Brown / Bachelor / Peter Weber / peter bachelor</p>
        <ul>
        @foreach($trandList as $trands)
            <li class="list-group-item"><h5>{{ $trands }}</h5></li>
        @endforeach
        </ul>
@endsection

Web Programming Tutorials Example with Demo

Read :

Read Also:  PHP Jquery Ajax Upload Multiple Images with Preview

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel view share multiple.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.