1. Go to this page and download the library: Download bajzany/table 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/ */
bajzany / table example snippets
interface ITestTable
{
/**
* @return TestTable
*/
public function create(): TestTable;
}
use Bajzany\Table\EntityTable;
use Bajzany\Table\RowsCollection;
class TestEntityTable extends EntityTable
{
/**
* @return string
*/
public function getEntityClass(): string
{
return EntityClass::class;
}
public function searchActionFailure(EntityTable $table, $selectValue)
{
$table->getQueryBuilder()->andWhere("e.failure LIKE :failure")
->setParameter('failure', '%' . $selectValue . '%');
}
/**
* @param RowsCollection $rowsCollection
* @throws \Bajzany\Table\Exceptions\TableException
*/
protected function create(RowsCollection $rowsCollection)
{
$this->addSort("e.date", "DESC");
$this->getPaginator()->setPageSize(4);
$this->createColumn("failure")
->setSearchable(TRUE)
->setSortable(TRUE)
->setLabel("Failure")
->setPattern("{{ failure }}")
->addFilter([$this->filter, "boolLabel"], ["label-danger", "label-success"])
->setSearchSelectOptions([
'0' => 'Ne',
'1' => 'Ano',
])
->onSearchAction[] = [$this, 'searchActionFailure'];
$this->createColumn("emailProbe")
->setSearchable(TRUE)
->setLabel("Email")
->setPattern("{{ emailProbe }}");
$this->createColumn("statusMessage")
->setLabel("Status")
->setPattern("{{ statusMessage }}");
$this->createColumn("ip")
->setLabel("IP")
->setPattern("{{ ip }}");
$this->createColumn("date")
->setLabel("date")
->setSortable(TRUE)
->setPattern("{{ date }}")
->addFilter([$this->filter, "dateTime"]);
$this->createColumn("date")
->useComponent("customComponent")
->onBodyCreate[] = [$this, "dateColumn"];
$this->createColumn("option")
->onBodyCreate[] = [$this, "optionColumn"];
}
/**
* @param string $name
* @param EntityClass $entity
*/
public function createComponentCustomComponent($name, EntityClass $entity)
{
return $this->customComponent->create();
}
public function optionColumn(Item $item, EntityClass $entity)
{
}
}
/**
* @var ITestEntityTable @inject
*/
public $testTable;
/**
* @param IGroupTable $groupTable
* @return GroupTable
*/
public function createComponentTestList(): GroupTable
{
$table = $testTable->create();
return $table;
}
namespace Bundles\User\Model;
use Bajzany\Table\EntityTable;
use Bajzany\Table\Listener\ITableSubscriber;
use Chomenko\AutoInstall\Config\Tag;
use Bajzany\Table\DI\TableExtensions;
/**
* @Tag({TableExtensions::TAG_EVENT=EntityClass::class})
*/
class UserTableSubscriber implements ITableSubscriber
{
public function onBuildQuery(EntityTable $entityTable)
{
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.