You can install the package via composer:
composer require foxws/livewire-presenter
You can publish the config file with:
php artisan vendor:publish --tag="livewire-presenter"
<?php
use Foxws\Presenter\Fields\Field;
use Foxws\Presenter\Presenter;
use Foxws\Presenter\Filters\Filter;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;
class UserOverviewController extends Presenter
{
public function mount()
{
//
}
public function render(): View
{
return view('users.overview')
->layout('layouts.app');
}
protected function builder(): LengthAwarePaginator
{
return User::all()
->paginate(perPage: $this->perPage);
}
protected function configure(): void
{
//
}
protected function fields(): array
{
return [
Field::new()
->name('name')
->label(__('Name'))
->component('users.presenter.name')
->sortable(),
Field::new()
->name('email')
->label(__('Email'))
->component('users.presenter.email'),
];
}
protected function filters(): array
{
return [
Filter::new()
->name('created_at')
->label(__('Created At'))
->value(now()->subDays(90)),
];
}
}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.