LaravelPackages.net
Acme Inc.
Toggle sidebar
morilog/widgetify

A powerful laravel widget package. capsulate ui componenet as widget. similar to Yii widgets

2.453
11
v1.0.0
About morilog/widgetify

morilog/widgetify is a Laravel package for a powerful laravel widget package. capsulate ui componenet as widget. similar to yii widgets. It currently has 11 GitHub stars and 2.453 downloads on Packagist (latest version v1.0.0). Install it with composer require morilog/widgetify. Discover more Laravel packages by morilog or browse all Laravel packages to compare alternatives.

Last updated

Widgetify

Laravel widget package for Laravel >= 5.1

Installation

composer require morilog/widgetify

Register in Laravel

  • Add Morilog\Widgetify\WidgetifyServiceProvider to config/app.php providers array

  • If you need to Facade for rendering widgets, add bellow in config/app.php aliases array :

	'Widgetify' => Morilog\Widgetify\Facades\Widgetify::class
  • For publish Widgetify config file, run this command:
php artisan vendor:publish --provider="Morilog\Widgetify\WidgetifyServiceProvider"

Usage

Create new widget

For creating new widget you must create a class that extended Morilog\Widgetify\Widget and implement handle() method.

<?php
namespace App\MyWidgets;

use Morilog\Widgetify\Widget;

class SimpleWidget extends Widget
{
	public function handle()
	{
		$latestPosts = Post::take(10)->get();

		return view('path.to.view.file', compact('latestPosts'));
	}
}

Registering Widget

  • Add your widget to widgets array in config/widgetify.php file:
	'widgets' => [
		'simple_widget' => App\MyWidgets\SimpleWidget::class
	]

Rendering Widgets

With blade @widgetify directive:

// views/sidebar.blade.php
<div class="col-sm-3">
	@widgetify('simple_widget')
</div>

OR with configs:

// views/sidebar.blade.php
<div class="col-sm-3">
	@widgetify('simple_widget', ['key' => 'value', 'key2' => 'value'])
</div>

OR with Widgetify Facade:

// views/sidebar.blade.php
<div class="col-sm-3">
	{!! Widgetify::render('simple_widgets') !!}
</div>

Using cache

// views/default.blade.php
<div class="col-sm-4">
    {!! Widgetify::remember('my_widget', 15, [CONFIGS]); !!}
</div>
<div class="col-sm-4">
    @cached_widgetify('my_widget', 15, [CONFIGS]);
</div>

Star History Chart