Skip to content

Commit 97642da

Browse files
committed
Add support for Laravel v10 & v11
1 parent ba80a6a commit 97642da

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "jangaraev/laravel-blade-cache",
33
"type": "library",
4+
"version": "1.0.3",
45
"description": "Handy package to cache blade files",
56
"keywords": ["laravel", "php", "views", "cache", "blade"],
67
"homepage": "https://github.com/jangaraev/laravel-blade-cache",
@@ -13,7 +14,7 @@
1314
],
1415
"require": {
1516
"php": ">=8.0",
16-
"illuminate/support": "^8.0|^9.0"
17+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
1718
},
1819
"autoload": {
1920
"psr-4": {
@@ -27,6 +28,6 @@
2728
]
2829
}
2930
},
30-
"minimum-stability": "dev",
31+
"minimum-stability": "stable",
3132
"prefer-stable": true
3233
}

src/BladeCache.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static function get(string $args): string
1313
{
1414
[$view, $ttl] = self::extractArgumentsFromDirective($args);
1515

16-
return Cache::remember(self::getQualifiedCacheKey($view), $ttl, function () use ($view) {
16+
return Cache::remember(self::getQualifiedCacheKey($view), $ttl * 60, function () use ($view) {
1717
return self::render($view);
1818
});
1919
}
@@ -27,9 +27,7 @@ public function reset(string $key): void
2727
}
2828

2929
foreach ($locales as $locale) {
30-
$cacheKey = self::getQualifiedCacheKey($key, $locale);
31-
32-
if (Cache::has($cacheKey)) {
30+
if (Cache::has($cacheKey = self::getQualifiedCacheKey($key, $locale))) {
3331
Cache::forget($cacheKey);
3432
}
3533
}
@@ -64,8 +62,12 @@ protected static function render(string $view): string
6462

6563
protected static function getQualifiedCacheKey(string $view, string $locale = null): string
6664
{
65+
$view = str_replace('.', '_', $view);
66+
6767
if (is_null($locale)) {
68-
$locale = App::getLocale();
68+
$locale = class_exists('LaravelLocalization')
69+
? LaravelLocalization::getCurrentLocale()
70+
: App::getLocale();
6971
}
7072

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

0 commit comments

Comments
 (0)