greabock / widget-system by greabock

Da epic widget-system for Laravel
1,180
29
7
Package Data
Maintainer Username: greabock
Maintainer Contact: greabock@gmail.com (Greabock)
Package Create Date: 2015-02-15
Package Last Update: 2015-02-21
Language: PHP
License: MIT
Last Refreshed: 2024-11-16 15:01:48
Package Statistics
Total Downloads: 1,180
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 29
Total Watchers: 7
Total Forks: 2
Total Open Issues: 0

#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') !!}