PHP code example of morilog / widgetify

1. Go to this page and download the library: Download morilog/widgetify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

morilog / widgetify example snippets


	'Widgetify' => Morilog\Widgetify\Facades\Widgetify::class


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' => [
		'simple_widget' => App\MyWidgets\SimpleWidget::class
	]

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

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

// 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>


php artisan vendor:publish --provider="Morilog\Widgetify\WidgetifyServiceProvider"