Skip to content

Commit

Permalink
Feat: better support for laravel-localization package & Laravel Octane
Browse files Browse the repository at this point in the history
  • Loading branch information
jangaraev committed Sep 14, 2022
1 parent ba80a6a commit 663d434
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/BladeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function get(string $args): string
{
[$view, $ttl] = self::extractArgumentsFromDirective($args);

return Cache::remember(self::getQualifiedCacheKey($view), $ttl, function () use ($view) {
return Cache::remember(self::getQualifiedCacheKey($view), $ttl * 60, function () use ($view) {
return self::render($view);
});
}
Expand All @@ -27,9 +27,7 @@ public function reset(string $key): void
}

foreach ($locales as $locale) {
$cacheKey = self::getQualifiedCacheKey($key, $locale);

if (Cache::has($cacheKey)) {
if (Cache::has($cacheKey = self::getQualifiedCacheKey($key, $locale))) {
Cache::forget($cacheKey);
}
}
Expand Down Expand Up @@ -64,8 +62,12 @@ protected static function render(string $view): string

protected static function getQualifiedCacheKey(string $view, string $locale = null): string
{
$view = str_replace('.', '_', $view);

if (is_null($locale)) {
$locale = App::getLocale();
$locale = class_exists('LaravelLocalization')
? LaravelLocalization::getCurrentLocale()
: App::getLocale();
}

return "blade-cache.{$view}.{$locale}";
Expand Down

0 comments on commit 663d434

Please sign in to comment.