1. Go to this page and download the library: Download wyxos/harmonie 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/ */
wyxos / harmonie example snippets
use Wyxos\Harmonie\Listing\ListingBase;
use Illuminate\Database\Eloquent\Builder;
use Laravel\Scout\Builder as ScoutBuilder;
class UserListing extends ListingBase
{
public function baseQuery()
{
return User::query();
}
public function filters(Builder|ScoutBuilder $base)
{
$this->whereLike($base, 'search', 'name');
$this->whereIn($base, 'roles');
$this->whereRange($base, 'created_at');
}
public function filterLabels(): array
{
return [
'search' => 'Search',
'roles' => 'Roles',
'created_from' => 'Created From',
'created_to' => 'Created To',
];
}
public function load($pagination)
{
$pagination->load('roles');
}
}
use Wyxos\Harmonie\Export\ExportBase;
use Illuminate\Database\Eloquent\Builder;
class UserExport extends ExportBase
{
public function filename($parameters = [])
{
return 'users-export-' . now()->format('Y-m-d');
}
public function query(array $parameters = []): Builder
{
return User::query();
}
public function format($row)
{
return [
'ID' => $row->id,
'Name' => $row->name,
'Email' => $row->email,
'Created At' => $row->created_at->format('Y-m-d H:i:s'),
];
}
public function chunkQuery(): Builder
{
return $this->query();
}
}