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


app/Http/routes.php

Route::get('/', 'DspController@index');
Route::get('/mobile', 'DspController@mobile');
Route::get('/store', 'DspController@store');
Route::get('/update', 'DspController@update');

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')
        

Latest The Bachelor 2020 - Reality Steve

Hannah Brown / Bachelor / Peter Weber / peter bachelor

    @foreach($trandList as $trands)
  • {{ $trands }}
  • @endforeach
@endsection
Web Programming Tutorials Example with Demo

Read :

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.

Leave a Comment