1. Go to this page and download the library: Download breda/laravel-alpha-widget library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
breda / laravel-alpha-widget example snippets
'providers' => [
// Other providers...
'BReda\AlphaWidget\ServiceProvider',
]
'aliases' => [
// Other aliases...
'AlphaWidget' => 'BReda\AlphaWidget\Facades\AlphaWidget',
// Of course, you can name the alias to whatever you want.
// ex:
// 'Widget' => 'BReda\AlphaWidget\Facades\AlphaWidget',
]
'widgets' => [
// Other widgets...
'myRecentUsersWidget' => 'RecentUsers',
]
AlphaWidget::render('myRecentUsersWidget');
// Or, a much better way:
AlphaWidget::myRecentUsersWidget();
namespace App\Widgets;
use BReda\AlphaWidget\Contracts\AlphaWidget as WidgetContract;
class RecentUsers implements WidgetContract
{
/**
* Render the Widget
*
* @return string
*/
public function render(){
return "Hello from the widget!";
}
}
AlphaWidget::render('myRecentUsersWidget', [5]);
// Or, a much better way:
AlphaWidget::myRecentUsersWidget(5);
namespace App\Widgets;
use BReda\AlphaWidget\Contracts\AlphaWidget as WidgetContract;
class RecentUsers implements WidgetContract
{
/**
* How much should we limit the displayed users.
*
* @var string
*/
protected $limit;
/**
* Create a new RecentUsers Widget instance
*
* @return void
*/
public function __construct($limit)
{
$this->limit = $limit;
}
/**
* Render the Widget
*
* @return mixed
*/
public function render(){
return "Displaying the {$this->limit} recently registerd users...";
}
}
namespace App\Widgets;
use App\Repositories\UsersRepository;
use BReda\AlphaWidget\Contracts\AlphaWidget as WidgetContract;
class RecentUsers implements WidgetContract
{
/**
* How much should we limit the displayed users.
*
* @var string
*/
protected $limit;
/**
* Create a new RecentUsers Widget instance
*
* @return void
*/
public function __construct($limit, UsersRepository $users)
{
$this->limit = $limit;
$this->users = $users;
}
/**
* Render the Widget
*
* @return mixed
*/
public function render(){
$users = $this->users->getRecentUsers($this->limit);
return view('widgets.recent-users', ['users' => $users]);
}
}
bash
$ php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.