68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Web\Components\Ui;
|
|
|
|
use Livewire\Component;
|
|
|
|
class Header extends Component
|
|
{
|
|
public $isMobileMenuOpen = false;
|
|
public $domainName;
|
|
public $domainUrl;
|
|
public $content = [];
|
|
|
|
public function mount()
|
|
{
|
|
$this->domainName = \App\Helpers\ThemeHelper::getDomainName();
|
|
$this->domainUrl = \App\Helpers\ThemeHelper::getDomainUrl();
|
|
$theme = config('app.theme', 'b2in');
|
|
$this->content = config("content.themes.{$theme}.header", [
|
|
'portal_login' => 'Portal Login',
|
|
'navigation' => []
|
|
]);
|
|
|
|
// Ensure required keys exist
|
|
if (!isset($this->content['portal_login'])) {
|
|
$this->content['portal_login'] = 'Portal Login';
|
|
}
|
|
if (!isset($this->content['navigation']) || !is_array($this->content['navigation'])) {
|
|
$this->content['navigation'] = [];
|
|
}
|
|
}
|
|
|
|
public function toggleMobileMenu()
|
|
{
|
|
$this->isMobileMenuOpen = ! $this->isMobileMenuOpen;
|
|
}
|
|
|
|
public function closeMobileMenu()
|
|
{
|
|
$this->isMobileMenuOpen = false;
|
|
}
|
|
public function isActiveRoute($url)
|
|
{
|
|
$currentPath = request()->path();
|
|
$currentPath = '/' . ltrim($currentPath, '/');
|
|
|
|
// Exact match
|
|
if ($currentPath === $url) {
|
|
return true;
|
|
}
|
|
|
|
// Special handling for home route
|
|
if ($url === '/' && ($currentPath === '/' || $currentPath === '')) {
|
|
return true;
|
|
}
|
|
|
|
// Check if current path starts with the navigation URL (for sub-pages)
|
|
if ($url !== '/' && str_starts_with($currentPath, rtrim($url, '/'))) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
public function render()
|
|
{
|
|
return view('livewire.web.components.ui.header');
|
|
}
|
|
}
|