unisharp/laravel-widgetify
Widget generator for Laravel
- Help you get partial views as widgets
Installation
-
install package
composer require unisharp/laravel-widgetify -
edit config/app.php
service provider :
Unisharp\Widget\WidgetServiceProvider::class,class aliases :
'Widget' => Unisharp\Widget\WidgetFacade::class, -
publish widget template class
php artisan vendor:publish --tag=widget_example
Usage
Widget::set('side', 'widget-class-name', $args = []]);
// set widgets with position
Widget::get('side');
// get all widgets of a position
Example
-
in
App\Widgets\Block.php:class Block implements WidgetInterface { public $view = 'home.widgets.side_html'; public function getData($args) { return ['html' => \App\Utility::getPageByAlias($args['alias'])]; } } -
in
home.widgets.side_html.blade.php:@if(!empty($html->content)) <section class="facebook-plugin"> {!! $html->content !!} </section> @endif -
set widgets in in controller :
\Widget::set('side', 'block', ['alias' => 'side_top_html']); \Widget::set('side', 'facebook'); \Widget::set('side', 'block', ['alias' => 'side_mid_html']); \Widget::set('side', 'subscription'); \Widget::set('side', 'block', ['alias' => 'side_buttom_html']); -
display widgets in view :
{!! \Widget::get('side') !!}
Related Packages
coolpraz/php-blade
The standalone version of Laravel's Blade templating engine for use outside of L...
8,784
9
jenssegers/blade
The standalone version of Laravel's Blade templating engine for use outside of L...
1,346,816
863
wilsonpinto/laravel-blade-directives
This package adds custom directives for the Laravel 5 blade engine.
71
3
tempest/blade
PHP 8.4 compatible fork of jenssegers/blade: a standalone version of Laravel's B...
91,267
2