Skip to content

Commit

Permalink
Add captin
Browse files Browse the repository at this point in the history
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
  • Loading branch information
Lloric Mayuga Garcia committed Aug 17, 2017
1 parent 4f8fe88 commit dec0047
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/LaravelHtmlTableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ class LaravelHtmlTableGenerator
*
* @type string
*/
private $_links;
private $_links;

/**
*
*
*
*
* @type string
*/
private $_caption;




/**
Expand All @@ -48,6 +59,7 @@ public function __construct()
$this->_links = NULL;
}



/**
*
Expand All @@ -61,13 +73,24 @@ public function __construct()
private function _header(array $header)
{
$output = $this->_tags['head'].$this->_tags['head_row'];

if(!is_null($this->_caption))
{
$output = "$output<caption>{$this->_caption}</caption>";
}

foreach($header as $row)
{
$output .= $this->_tags['head_cell'].$row.$this->_tags['head_cell_end'];
}
return $output.$this->_tags['head_row_end'].$this->_tags['head_end'];
}


private function _setCaption($caption)
{
$this->_caption = $caption;
}


/**
Expand Down Expand Up @@ -260,8 +283,10 @@ private function _checTagsFromAttrbutes()
* @return string
* @author Lloric Mayuga Garcia <[email protected]>
*/
public function generateTable($header, $data = [],$attributes = [])
public function generateTable($header, $data = [],$attributes = [], $caption = null)
{
$this->_setCaption($caption);

$this->_attributes = $attributes;
$this->_checTagsFromAttrbutes();
return $this->_generate($header ,$data);
Expand All @@ -280,8 +305,10 @@ public function generateTable($header, $data = [],$attributes = [])
* @return string
* @author Lloric Mayuga Garcia <[email protected]>
*/
public function generateTableFromModel($header, $model,array $fields, $limit, $attributes = [])
public function generateTableFromModel($header, $model,array $fields, $limit, $attributes = [], $caption = null)
{
$this->_setCaption($caption);

$this->_attributes = $attributes;
$this->_checTagsFromAttrbutes();
return $this->_generate($header, $model, $limit, $fields);
Expand Down

0 comments on commit dec0047

Please sign in to comment.