themes how part of site settings
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
namespace Modules\Stylist\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Settings\Services\SettingsRepository;
|
||||
|
||||
final class TenantThemeResolver
|
||||
{
|
||||
public function resolve(): string
|
||||
public function __construct(private readonly SettingsRepository $settings) {}
|
||||
|
||||
public function resolve(?string $context = null): string
|
||||
{
|
||||
$context ??= $this->context();
|
||||
$column = config('stylist.tenant_theme_column', 'theme_key');
|
||||
$user = Auth::user();
|
||||
$company = $user?->company ?? null;
|
||||
@@ -23,7 +27,26 @@ final class TenantThemeResolver
|
||||
}
|
||||
}
|
||||
|
||||
return config('stylist.default_theme', 'default');
|
||||
$settingKey = $context === 'frontend' ? 'frontend_theme' : 'backend_theme';
|
||||
$default = $context === 'frontend'
|
||||
? config('stylist.default_frontend_theme', 'saasland')
|
||||
: config('stylist.default_backend_theme', config('stylist.default_theme', 'admin'));
|
||||
|
||||
return (string) $this->settings->get($settingKey, $default, 'site');
|
||||
}
|
||||
|
||||
public function context(): string
|
||||
{
|
||||
if (app()->runningInConsole()) {
|
||||
return 'backend';
|
||||
}
|
||||
|
||||
$request = request();
|
||||
|
||||
return $request->routeIs('home', 'blog.public.*', 'news.public.*', 'pages.public.*')
|
||||
|| ! $request->user()
|
||||
? 'frontend'
|
||||
: 'backend';
|
||||
}
|
||||
|
||||
public function variables(): array
|
||||
|
||||
Reference in New Issue
Block a user