Skip to content

Commit dec0047

Browse files
author
Lloric Mayuga Garcia
committed
Add captin
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
1 parent 4f8fe88 commit dec0047

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/LaravelHtmlTableGenerator.php

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@ class LaravelHtmlTableGenerator
3333
*
3434
* @type string
3535
*/
36-
private $_links;
36+
private $_links;
37+
38+
/**
39+
*
40+
*
41+
*
42+
*
43+
* @type string
44+
*/
45+
private $_caption;
46+
47+
3748

3849

3950
/**
@@ -48,6 +59,7 @@ public function __construct()
4859
$this->_links = NULL;
4960
}
5061

62+
5163

5264
/**
5365
*
@@ -61,13 +73,24 @@ public function __construct()
6173
private function _header(array $header)
6274
{
6375
$output = $this->_tags['head'].$this->_tags['head_row'];
76+
77+
if(!is_null($this->_caption))
78+
{
79+
$output = "$output<caption>{$this->_caption}</caption>";
80+
}
81+
6482
foreach($header as $row)
6583
{
6684
$output .= $this->_tags['head_cell'].$row.$this->_tags['head_cell_end'];
6785
}
6886
return $output.$this->_tags['head_row_end'].$this->_tags['head_end'];
6987
}
7088

89+
90+
private function _setCaption($caption)
91+
{
92+
$this->_caption = $caption;
93+
}
7194

7295

7396
/**
@@ -260,8 +283,10 @@ private function _checTagsFromAttrbutes()
260283
* @return string
261284
* @author Lloric Mayuga Garcia <[email protected]>
262285
*/
263-
public function generateTable($header, $data = [],$attributes = [])
286+
public function generateTable($header, $data = [],$attributes = [], $caption = null)
264287
{
288+
$this->_setCaption($caption);
289+
265290
$this->_attributes = $attributes;
266291
$this->_checTagsFromAttrbutes();
267292
return $this->_generate($header ,$data);
@@ -280,8 +305,10 @@ public function generateTable($header, $data = [],$attributes = [])
280305
* @return string
281306
* @author Lloric Mayuga Garcia <[email protected]>
282307
*/
283-
public function generateTableFromModel($header, $model,array $fields, $limit, $attributes = [])
308+
public function generateTableFromModel($header, $model,array $fields, $limit, $attributes = [], $caption = null)
284309
{
310+
$this->_setCaption($caption);
311+
285312
$this->_attributes = $attributes;
286313
$this->_checTagsFromAttrbutes();
287314
return $this->_generate($header, $model, $limit, $fields);

0 commit comments

Comments
 (0)