Download the PHP package breda/laravel-alpha-widget without Composer
On this page you can find all versions of the php package breda/laravel-alpha-widget. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download breda/laravel-alpha-widget
More information about breda/laravel-alpha-widget
Files in breda/laravel-alpha-widget
Package laravel-alpha-widget
Short Description Simple Widget Manager For Laravel 5
License
Homepage https://github.com/breda/laravel-alpha-widget
Informations about the package laravel-alpha-widget
AlphaWidget — Widgets For Laravel 5
This is a very simple, easy to use Widget manager for Laravel 5
Installation
First, install the package via Composer.
in the config/app.php
file, add the Service Provider
Then, register the alias :
And, lastly... publish the AlphaWidget configuration file to your config
directory:
And you're ready to use AlphaWidget!
Walk Through
Now, when I said that this is a simple Widget manager, I meant it! It's as simple as registering a widget alias, and it's class inside the configuration file. Like this :
One note to take here before we move on, is that I'am only referencing the class name, not the complete namespace. And that's what the
namespace
field in theconfig/alphaWidget.php
file is here for.To shorten class names, put your desired namespace in the config file, just make sure that all of your widget classes declare that namespace, that's all!
And then, calling the widget is as simple as :
Now, what does that RecentUsers
look like, I hear you say!
It's a simple class implementing the AlphaWidget
Contract (interface), stating that it must have the render
method. That method, is responsible of rendering the widget contents.
One note to take here! Is that the
render
method, shouldreturn
the contents, and NOTecho
them out! Remember! Noecho
! Justreturn
.Another note
Passing Arguments To Widget Calls
You can of course, pass arguments to widget calls. Like this for example:
And then in your class:
Now! One last thing to note! Since all widgets are resolved through the Laravel's IoC container, you can type-hint any Laravel Service to be used in your Widget class!
Practical Example
An good example, would be fetching the 5 recently registered users.
And that's it really!
Contributing
Anything from bug fixes, improvements or anything similar! Pull requests are welcome! Just make sure to submit them to the develop
branch, rather to the master
branch, as this later only has production-ready code.
All versions of laravel-alpha-widget with dependencies
illuminate/contracts Version 5.0.*
illuminate/container Version 5.0.*