mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-02 21:16:12 -04:00
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
namespace Modules\MenuPlus\Services;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Modules\Appearance\Repositories\ThemeColorRepository;
|
|
|
|
class CommonService
|
|
{
|
|
public function getThemeColor() {
|
|
$repository = new ThemeColorRepository();
|
|
$themeColor = $repository->activeColor();
|
|
|
|
return $themeColor;
|
|
}
|
|
|
|
public function isVisible($element) {
|
|
$metas = $element->metas;
|
|
if (count($metas) > 0) {
|
|
$audience = null;
|
|
$roles = null;
|
|
for ($i = 0; $i < count($metas); $i++) {
|
|
$meta = $metas[$i];
|
|
if ($meta->meta_name == 'audience') {
|
|
$audience = $meta->meta_value;
|
|
}
|
|
else if ($meta->meta_name == 'roles') {
|
|
$roles = trim($meta->meta_value);
|
|
}
|
|
}
|
|
|
|
if ($audience == 'everyone') {
|
|
return true;
|
|
}
|
|
else if ($audience == 'logged-in-users') {
|
|
if (auth()->user()) {
|
|
if ($roles) {
|
|
if (strstr($roles, auth()->user()->role->id)) {
|
|
return true;
|
|
}
|
|
}
|
|
else {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else if ($audience == 'logged-out-users') {
|
|
if (!Auth::check()) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |