greabock/widget-system

Da epic widget-system for Laravel

dev-master / 0.1.x-dev 2015-02-21 06:25 UTC

This package is auto-updated.

Last update: 2024-10-09 13:28:49 UTC


README

#DA EPIC WIDGET-SYSTEM laravel widget-system

composer

"greabock/widget-system": "dev-master"

facade

'Widget'=> 'Greabock\Widget\Facade'

Example Widget

<?php namespace App\Widgets;

class MyCustomWidget { 

	protected $something;

	public function __construct(SomeRepository $repository)
	{
		$this->something = $repository->getSomething();
	}
	
	
	public function render($param)
	{
		$data = [
			'something' => $this->something,
			'someElse'  => $param,
		];
		
		return view('view', $data);
	}
}

Registration:

Widget::register('App\Widgets\MyCustomWidget', 'myWidget' );

Template:

{!! Widget::show('myWidget', 'param') !!}
{-- or --}
{!! Widget::myWidget('param') !!}

Positions

Widget::register('App\Widgets\MyCustomWidget', 'myWidget', 'menu_position', 1 );
Widget::register('App\Widgets\OtherCustomWidget', 'OtherWidget', 'menu_position', 2 );

Template:

{!! Widget::position('menu_position') !!}
// same as
{!! Widget::show('myWidget') !!}
{!! Widget::show('OtherWidget') !!}