-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,18 @@ class LaravelHtmlTableGenerator | |
* | ||
* @type string | ||
*/ | ||
private $_links; | ||
private $_links; | ||
|
||
/** | ||
* | ||
* | ||
* | ||
* | ||
* @type string | ||
*/ | ||
private $_caption; | ||
|
||
|
||
|
||
|
||
/** | ||
|
@@ -48,6 +59,7 @@ public function __construct() | |
$this->_links = NULL; | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
|
@@ -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; | ||
} | ||
|
||
|
||
/** | ||
|
@@ -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); | ||
|
@@ -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); | ||
|