From 7464decb8ea3737192b0e3d76070599faee2abed Mon Sep 17 00:00:00 2001 From: Wisp X <1591788658@qq.com> Date: Sun, 13 Mar 2022 20:02:26 +0800 Subject: [PATCH] fix a bug --- app/Http/Controllers/Controller.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index ac2b67b1..87daadcf 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -144,7 +144,7 @@ class Controller extends BaseController ->where('key', $request->route('key')) ->where('extension', strtolower($request->route('extension'))) ->firstOr(fn() => abort(404)); - if (! $image->group->configs->get(GroupConfigKey::IsEnableOriginalProtection)) { + if (! $image->group?->configs->get(GroupConfigKey::IsEnableOriginalProtection)) { abort(404); } try { @@ -155,11 +155,11 @@ class Controller extends BaseController } else { $contents = $image->filesystem()->read($image->pathname); // 是否启用了水印功能,跳过gif图片 - if ($image->group->configs->get(GroupConfigKey::IsEnableWatermark) && $image->mimetype !== 'image/gif') { - $configs = $image->group->configs->get(GroupConfigKey::WatermarkConfigs); + if ($image->group?->configs->get(GroupConfigKey::IsEnableWatermark) && $image->mimetype !== 'image/gif') { + $configs = $image->group?->configs->get(GroupConfigKey::WatermarkConfigs); $contents = $service->stickWatermark($contents, collect($configs))->encode()->getEncoded(); } - $cacheTtl = (int)$image->group->configs->get(GroupConfigKey::ImageCacheTtl, 0); + $cacheTtl = (int)$image->group?->configs->get(GroupConfigKey::ImageCacheTtl, 0); // 是否启用了缓存 if ($cacheTtl) { Cache::remember($cacheKey, $cacheTtl, fn () => $contents);