1. Go to this page and download the library: Download inlayphp/widgets 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/ */
inlayphp / widgets example snippets
use Inlay\Widgets\ChartWidget;
use Inlay\Actions\Action;
use Inlay\Widgets\Dashboard;
use Inlay\Widgets\FormWidget;
use Inlay\Widgets\InfolistWidget;
use Inlay\Forms\Form;
use Inlay\Infolists\Infolist;
use Inlay\Widgets\Stat;
use Inlay\Widgets\StatsOverviewWidget;
use Inlay\Widgets\TableWidget;
use Inlay\Widgets\WidgetDashboard;
$dashboard = WidgetDashboard::make()
->columns(12)
->widgets([
StatsOverviewWidget::make('overview')
->label('Today')
->columns(3)
->headerActions([
Action::make('create-order')->label('New order')->url('/admin/orders/create'),
])
->footerActions([
Action::make('view-orders')->label('View all orders')->url('/admin/orders'),
])
->stats([
Stat::make('Revenue', '$42,180')
->description('12% above yesterday')
->icon('currency-dollar')
->color('success')
->trend('up')
->url('/admin/orders')
->chart([18, 21, 20, 25, 29, 31, 36]),
Stat::make('Orders', 284),
]),
ChartWidget::make('signups')
->label('New signups')
->description('Last five weekdays')
->chartType('bar')
->labels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
->dataset('Users', [12, 18, 15, 27, 31], '#4f46e5')
->columnSpan(8)
->sort(10),
TableWidget::make('latest-users')
->label('Latest users')
->table($usersTable)
->columnSpan(4)
->sort(20),
]);
$panel->dashboard(Dashboard::make()
->eyebrow('Resource management')
->heading('Orders overview')
->description('A PHP-defined dashboard with shared Inlay surfaces.')
->headerActions([
Action::make('create-order')
->label('New order')
->url('/admin/orders')
->method('post'),
]));
// FormWidget and InfolistWidget accept the normal PHP Form and Infolist
// builders. They render inside the same responsive widget grid as tables.
$dashboard->widgets([
FormWidget::make('quick-edit')
->form(Form::make('quick-edit')->schema([]))
->columnSpan(4)
->columnStart(9)
->tab('overview'),
InfolistWidget::make('details')
->infolist(Infolist::make('details')->schema([]))
->columnSpan(4)
->columnStart(9)
->tab('overview'),
]);
use Illuminate\Http\Request;
use Inlay\Widgets\Contracts\CacheableWidgets;
final class AdminDashboardWidgets implements CacheableWidgets
{
public function cacheKey(Request $request): string
{
$user = $request->user();
return 'inlay.dashboard.'.$user->getAuthIdentifier().'.'.$request->getLocale();
}
public function cacheTtl(Request $request): int
{
return 30;
}
public function widgets(Request $request): iterable
{
yield StatsOverviewWidget::make('account')
->stats([
Stat::make('Open orders', $request->user()->orders()->open()->count()),
]);
}
}
use Illuminate\Http\Request;
use Inlay\Widgets\Contracts\ProvidesWidgets;
use Inlay\Widgets\Stat;
use Inlay\Widgets\StatsOverviewWidget;
final class AdminDashboardWidgets implements ProvidesWidgets
{
public function widgets(Request $request): iterable
{
yield StatsOverviewWidget::make('account')
->stats([
Stat::make('Open orders', $request->user()->orders()->open()->count()),
]);
}
}
$panel
->widget(AdminDashboardWidgets::class)
->widget(ChartWidget::make('traffic')->labels([]));