Add Site Translation Management: Created SiteTranslation resource with pages for listing, creating, and editing translations. Implemented localization support for translation keys and values, enhancing the admin panel's usability for managing site translations. Introduced a new migration for the site_translations table and updated helper functions for translation retrieval.

This commit is contained in:
Ümit Tunç
2025-12-30 23:41:32 +03:00
parent f381caaa39
commit 064ec327ba
13 changed files with 376 additions and 252 deletions
+32 -2
View File
@@ -1,6 +1,8 @@
<?php
use App\Models\Setting;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
if (!function_exists('setting')) {
/**
@@ -12,7 +14,35 @@ if (!function_exists('setting')) {
*/
function setting(string $key, $default = null)
{
return Setting::get($key, $default);
// Cache settings to avoid database queries on every call
// Cache will store the full setting object to access type info
$setting = Cache::remember("app_setting_{$key}", 60 * 60 * 24, function () use ($key) {
return Setting::where('key', $key)
->where('is_active', true)
->first();
});
if (!$setting) {
return $default;
}
$value = $setting->value;
// Handle file/image types
if (in_array($setting->type, ['file', 'image']) || $key === 'home_hero') {
if (empty($value)) {
return $default;
}
// If value is already a URL, return it
if (filter_var($value, FILTER_VALIDATE_URL)) {
return $value;
}
// Return storage URL
return Storage::url($value);
}
return $value;
}
}