本文整理汇总了PHP中Renderer::generateTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Renderer::generateTable方法的具体用法?PHP Renderer::generateTable怎么用?PHP Renderer::generateTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer::generateTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateAjaxListFromRelation
/**
* @param $title
* @param $parentModel
* @param $relation
* @param string $identityKey
*/
public static function generateAjaxListFromRelation($title, $parentModel, $relation, $showFields = array(), $headerNames = array(), $selectsOptions = array())
{
/* @var $relation \Illuminate\Database\Eloquent\Relations\HasMany */
$relationName = $relation;
$relation = $parentModel->{$relation}();
$renderer = new Renderer();
$headers = array();
$arrayTable = array();
$paramsRows = array();
$tableParams['data-parent-id'] = $parentModel->getKey();
$tableParams['data-controller'] = url('ajax-list');
$tableParams['data-params'] = get_class($parentModel) . '/' . $relationName;
$tableParams['data-token'] = md5($title);
$result = '<div class="row ajaxListContainer">
<div class="col-md-12">
<fieldset>
<legend>
' . $title . '
</legend>
<div class="row">
<div class="col-md-12 ajaxList">';
if ($relation->count() > 0) {
foreach ($relation->get() as $row) {
$inputs = $renderer->getInputsFromRow($row, $showFields, $selectsOptions);
$rowTable = array();
foreach ($inputs as $fieldName => $htmlInput) {
$rowTable[$fieldName] = $htmlInput;
$headers[$fieldName] = $fieldName;
if (isset($headerNames[$fieldName])) {
$headers[$fieldName] = $headerNames[$fieldName];
}
}
$rowTable['acciones'] = '<i style="cursor: pointer;" class="fa fa-remove removeListRow"></i>';
$rowParams['data-id'] = $row->getKey();
$paramsRows[] = $rowParams;
$arrayTable[] = $rowTable;
}
$headers['acciones'] = "Acciones";
$ajaxListParams = array($title, $parentModel, $relationName, $showFields, $headerNames, $selectsOptions);
\Session::set(self::PREFIX_SESSION_AJAX_LIST . $tableParams['data-token'], $ajaxListParams);
}
$table = $renderer->generateTable($headers, $arrayTable, $tableParams, $paramsRows);
$result .= $table;
$result .= ' <button class="btn addItem">Añadir item</button>
</div>
</div>
</fieldset>
<hr>
</div>
</div>';
$result .= $renderer->renderJS();
return $result;
}