⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.101
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Server Software:
Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.25
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
ebook.dev-unit.com
/
Modules
/
Admin
/
Ui
/
View File Name :
CiTab.php
<?php namespace Modules\Admin\Ui; use Illuminate\Support\ViewErrorBag; class CiTab { /** * Active state of the tab. * * @var bool */ private $active = false; /** * Name of the tab. * * @var string */ private $name; /** * Label of the tab. * * @var string */ private $label; /** * Weight of the tab. * * @var int */ private $weight = 0; /** * Available fields on the tab. * * @var array */ private $fields = []; /** * View of the tab. * * @var string|\Closure */ private $view; /** * Data for the tab view. * * @var array */ private $data; /** * Error message bag. * * @var \Illuminate\Support\ViewErrorBag */ private $errors; /** * Create a new Tab instance. * * @param string $name * @param string $label * @return void */ public function __construct($name, $label) { $this->name = $name; $this->label = $label; $this->errors = request()->session()->get('errors') ?: new ViewErrorBag; } /** * Set tab as active. * * @return self */ public function active() { $this->active = true; return $this; } /** * Set weight of tab. * * @param int $weight * @return self */ public function weight($weight) { $this->weight = $weight; return $this; } /** * Get weight of the tab. * * @return int */ public function getWeight() { return $this->weight; } /** * Get nav of the tab. * * @param array $data * @return string */ public function getNav() { /* return "<li class='{$this->activeClass()} {$this->errorClass()}'> <a href='#{$this->name}' data-toggle='tab'>{$this->label}</a> </li>"; */ return "<a class='nav-link {$this->activeClass()} {$this->errorClass()}' id='{$this->name}-tab' data-toggle='pill' href='#{$this->name}' role='tab' aria-controls='{$this->name}' aria-selected='{ ($this->active) ? true : false }'>{$this->label}</a>"; } /** * Return active class if tab is active. * * @return string */ private function activeClass() { return $this->active ? 'active' : ''; } /** * Return error class if tab fields has any error. * * @return string */ private function errorClass() { return $this->errors->hasAny($this->fields) ? 'has-error' : ''; } /** * Set fields of the tab. * * @param array|string $fields * @return self */ public function fields($fields) { $this->fields = is_array($fields) ? $fields : func_get_args(); return $this; } /** * Get fields of the tab. * * @return array */ public function getFields() { return $this->fields; } /** * Set view of the tab. * * @param \Closure|string $view * @param array $data * @return self */ public function view($view, $data = []) { $this->view = $view; $this->data = $data; return $this; } /** * Get view of the tab. * * @param array $data * @return string */ public function getView($data = []) { $html = "<div class='tab-pane fade show {$this->activeClass()}' id='{$this->name}' role='tabpanel' aria-labelledby='{$this->name}-tab'>"; $html .= "<div class='card'>"; $html .= "<div class='card-header'><div class='card-title'>{$this->label}</div></div>"; $html .= "<div class='card-body'>"; if (is_callable($this->view)) { $html .= call_user_func($this->view, array_merge($this->data, $data)); } else { $html .= view($this->view)->with(array_merge($this->data, $data))->render(); } $html .= '</div>'; $html .= '<div class="card-action text-right">'.view('admin::include.form.footer')->render().'</div>'; return $html .= '</div></div>'; } }