Package Data | |
---|---|
Maintainer Username: | morilog |
Maintainer Contact: | m.parvini@outlook.com (Morteza Parvini) |
Package Create Date: | 2016-11-08 |
Package Last Update: | 2018-01-22 |
Home Page: | https://github.com/morilog/widgetify |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:19:13 |
Package Statistics | |
---|---|
Total Downloads: | 2,389 |
Monthly Downloads: | 94 |
Daily Downloads: | 0 |
Total Stars: | 11 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Laravel widget package for Laravel >= 5.1
composer require morilog/widgetify
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
php artisan vendor:publish --provider="Morilog\Widgetify\WidgetifyServiceProvider"
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'));
}
}
widgets
array in config/widgetify.php
file: 'widgets' => [
'simple_widget' => App\MyWidgets\SimpleWidget::class
]
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>
// 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>