| @@ 46-60 (lines=15) @@ | ||
| 43 | * |
|
| 44 | * @return $this |
|
| 45 | */ |
|
| 46 | public function add($title, $content, $active = false, $id = null) |
|
| 47 | { |
|
| 48 | $this->data['tabs'][] = [ |
|
| 49 | 'id' => $id ?: mt_rand(), |
|
| 50 | 'title' => $title, |
|
| 51 | 'content' => $content, |
|
| 52 | 'type' => static::TYPE_CONTENT, |
|
| 53 | ]; |
|
| 54 | ||
| 55 | if ($active) { |
|
| 56 | $this->data['active'] = count($this->data['tabs']) - 1; |
|
| 57 | } |
|
| 58 | ||
| 59 | return $this; |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Add a link on tab. |
|
| @@ 71-85 (lines=15) @@ | ||
| 68 | * |
|
| 69 | * @return $this |
|
| 70 | */ |
|
| 71 | public function addLink($title, $href, $active = false) |
|
| 72 | { |
|
| 73 | $this->data['tabs'][] = [ |
|
| 74 | 'id' => mt_rand(), |
|
| 75 | 'title' => $title, |
|
| 76 | 'href' => $href, |
|
| 77 | 'type' => static::TYPE_LINK, |
|
| 78 | ]; |
|
| 79 | ||
| 80 | if ($active) { |
|
| 81 | $this->data['active'] = count($this->data['tabs']) - 1; |
|
| 82 | } |
|
| 83 | ||
| 84 | return $this; |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Set title. |
|