greabock / widget-system
Da epic widget-system for Laravel
Installs: 1 181
Dependents: 0
Suggesters: 0
Security: 0
Stars: 29
Watchers: 7
Forks: 2
Open Issues: 0
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-12-09 13:49:12 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') !!}