Manage/Create Laravel 5/6/7 Widgets Using Blade files

Today, We want to share with you Manage/Create Laravel 5/6/7 Widgets Using Blade files.In this post we will show you Laravel Widgets Package, hear for Using Blade files as Widgets in Laravel we will give you demo and example for implement.In this post, we will learn about laravel-widgetize with an example.

Manage/Create Laravel 5/6/7 Widgets Using Blade files

There are the Following The simple About Easy way to manage widgets in Laravel 5 Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel nova tutorial, so the class arrilot widgets serviceprovider not found is used for this example is following below.

Read Also:  Get Gravatar Image Using PHP Example

Laravel is a web application framework with expressive, elegant syntax.The PHP Framework for Web Artisans,freeing you to create without sweating the small things. CRUD Operation With Server Side.

Keywords : laravel 5,php,widgets,create,facade,example,code,pingpong,widget,laravel 5.2,use,view, laravel 5 widgets example,laravel 5 widget use, widgets laravel, widgets laravel 5.2, laravel dashboard widgets, menu bar widgets laravel

Phase 1: Installation

composer.json

"pingpong/widget" : "~2.0"

and then run command composer update

config/app.php

'providers' => [
	....
	'Pingpong\Widget\WidgetServiceProvider',
],

'aliases' => [
	....
	'Widget' => 'Pingpong\Widget\WidgetFacade'
],

Phase 2: Make a app/widgets.php

app/widgets.php

class MunuBarWidget {
    public function namageMenu($value)
    {
        switch ($value) {
            case 'homepage':
                $body = '<ul>';
                $body = $body.'<li>Home 1</li>';
                $body = $body.'<li>About 2</li>';
                $body = $body.'<li>Contact 3</li>';
                $body = $body.'</ul>';
                break;
            case 'sidebar':
                $body = '<ul>';
                $body = $body.'<li>Mobile 1</li>';
                $body = $body.'<li>Iphone 2</li>';
                $body = $body.'<li>Laptop 3</li>';
                $body = $body.'</ul>';
                break;
            default:
                $body = '<ul>';
                $body = $body.'<li>Red 1</li>';
                $body = $body.'<li>Green 2</li>';
                $body = $body.'<li>Blue 3</li>';
                $body = $body.'</ul>';
                break;
        }
        return $body;
    }
} 
Widget::register('navmenuitem', '[email protected]');

Phase 3: create route

routes.php file:

Route::get('/', function () {
	return view('home');
});

Phase 4: Use Widgets in view

resources/views/home.blade.php

<html>
    <head>
        <title>Laravel 5.2</title>
    </head>
    <body>
        <div class="container">
            <div class="content">
                <h1>HomePage</h1>
                {!! Widget::navmenuitem('homepage') !!}
                <h1>SideBar</h1>
                {!! Widget::navmenuitem('sidebar') !!}
            </div>
        </div>
    </body>
</html>

Web Programming Tutorials Example with Demo

Read :

Read Also:  Laravel 5.8 Form Validation Using Jquery

Summary

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

I hope you get an idea about Widgets for Laravel.
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 Reply

Your email address will not be published. Required fields are marked *