PHP code example of fantismic / yet-another-table
1. Go to this page and download the library: Download fantismic/yet-another-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/ */
fantismic / yet-another-table example snippets
php artisan vendor:publish --provider="Fantismic\\YetAnotherTable\\YATProvider" --tag="migrations"
php artisan migrate
php artisan vendor:publish --provider="Fantismic\\YetAnotherTable\\YATProvider" --tag="lang"
php artisan make:yatable MyBrandNewTable
$this->overrideTitleClasses('text-3xl text-red-700 dark:text-red-300');
$this->addTableClasses('text-xl');
$this->setStickyHeader();
$this->useTableSpinner();
$this->setTableSpinnerView('myviews.myspinner');
$this->setModalsView('myviews.mymodals');
$this->setSortColumn('createtime');
$this->setSortDirectionAsc(true);
$this->setSortDirectionDesc(true);
$this->setSearchLabel('Find');
$ids = $this->getSelectedWRows();
$this->removeRowFromTable(3);
$this->useStateHandler(true);
$this->setPerPageDefault(25);
$this->setColumnID('ticket');
$this->showColumnToggle(false);
public function columns(): array {
return [
Column::make('Name','name')
->styling('text-lg font-bold')
->hideFromSelector(true),
Column::make('Hex Code','hex'),
Column::make('Color')
->customData(function($row, $value){
return '<span style="color:'.$row['hex'].'">██████████████</span>';
})
->toHtml(),
LinkColumn::make('Google it','name')
->href(function($row, $value){
return "https://www.google.com/search?q=".$value;
})
->text('Google'),
BoolColumn::make('Primary','isPrimary')
];
}
Column::make('Upper Name','name')
->customData(function($row, $value){
return strtoupper($value);
})
Column::make('Full Name')
->customData(function($row, $value){
return $row['firstname'] . " " . $row['lastname'];
})
Column::make('Big Name','name')
->customData(function($row, $value){
return '<div class="text-3xl">'.$value.'</div>';
})->toHtml()
LinkColumn::make('Edit user','id')
->text('Edit')
->href(function($row, $value){
return '/edit/'.$value;
})
public function filters(): array {
return [
FilterString::make('name'),
FilterDateRange::make('Created At')
];
}
public function options(): array {
return [
'export' => 'Export selected rows',
'remove' => 'Delete selected rows',
];
}
public function remove() {
foreach ($this->getSelectedRows() as $id) {
$this->removeRowFromTable($id);
}
}