Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/morilog/widgetify

Powerful Widgets System For Laravel Farmework
https://github.com/morilog/widgetify

cache laravel laravel-5-package modular widget

Last synced: 2 months ago
JSON representation

Powerful Widgets System For Laravel Farmework

Awesome Lists containing this project

README

        

# Widgetify
Laravel widget package for Laravel >= 5.1

## Installation
```
composer require morilog/widgetify
```
#### Register in Laravel
- 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 :
```php
'Widgetify' => Morilog\Widgetify\Facades\Widgetify::class
```

- For publish Widgetify config file, run this command:
```
php artisan vendor:publish --provider="Morilog\Widgetify\WidgetifyServiceProvider"
```

---
## Usage
#### Create new widget
For creating new widget you must create a class that extended `Morilog\Widgetify\Widget` and implement `handle()` method.
```php
get();

return view('path.to.view.file', compact('latestPosts'));
}
}

```

#### Registering Widget
- Add your widget to `widgets` array in `config/widgetify.php` file:

```php
'widgets' => [
'simple_widget' => App\MyWidgets\SimpleWidget::class
]
```

#### Rendering Widgets
With blade `@widgetify` directive:
```php
// views/sidebar.blade.php


@widgetify('simple_widget')

```

OR with configs:
```php
// views/sidebar.blade.php


@widgetify('simple_widget', ['key' => 'value', 'key2' => 'value'])

```

OR with `Widgetify` Facade:
```php
// views/sidebar.blade.php


{!! Widgetify::render('simple_widgets') !!}

```

#### Using cache
```php
// views/default.blade.php


{!! Widgetify::remember('my_widget', 15, [CONFIGS]); !!}


@cached_widgetify('my_widget', 15, [CONFIGS]);

```