public function simple_table()
{
$data = [
'first key' => 'first text',
'second key' => 'second text',
'third key' => 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably havent heard of them accusamus labore sustainable VHS.',
'fourth key' => '44444',
];
return _class('html')->simple_table($data, [
'key' => [
'func' => function ($in) {
return '<b>' . $in . '</b>';
},
'extra' => [
'width' => '20%',
],
],
'tr' => function ($row, $id) {
return $id === 2 ? ['class' => 'success'] : '';
},
'td' => function ($row, $name, $row_id) {
return $row_id === 1 && $name == 'key' ? ['class' => 'info'] : '';
},
]);
}
public function simple_table($replace = [], $extra = [])
{
if ( ! $replace) {
return false;
}
$key_name = isset($extra['key']['name']) ? $extra['key']['name'] : 'key';
$val_name = isset($extra['val']['name']) ? $extra['val']['name'] : 'val';
$key_extra = isset($extra['key']['extra']) ? $extra['key']['extra'] : [];
$val_extra = isset($extra['val']['extra']) ? $extra['val']['extra'] : [];
$key_func = isset($extra['key']['func']) ? $extra['key']['func'] : 'text';
if ( ! is_string($key_func) && is_callable($key_func)) {
$key_callable = $key_func;
$key_func = 'func';
}
$val_func = isset($extra['val']['func']) ? $extra['val']['func'] : 'text';
if ( ! is_string($val_func) && is_callable($val_func)) {
$val_callable = $val_func;
$val_func = 'func';
}
$data = [];
foreach ((array) $replace as $k => $v) {
$data[] = [
$key_name => $k,
$val_name => $v,
];
}
$extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__];
$extra['no_header'] = isset($extra['no_header']) ? $extra['no_header'] : 1;
$extra['pager_records_on_page'] = isset($extra['pager_records_on_page']) ? $extra['pager_records_on_page'] : 10000;
$extra['no_total'] = isset($extra['no_total']) ? $extra['no_total'] : true;
$extra['no_pages'] = isset($extra['no_pages']) ? $extra['no_pages'] : true;
$extra['hide_empty'] = isset($extra['hide_empty']) ? $extra['hide_empty'] : true;
return table($data, $extra)
->$key_func($key_name, $key_callable, $key_extra)
->$val_func($val_name, $val_callable, $val_extra);
}