From 09e3e50e84561d73cad7cb6519496a6b7a6bb76d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 03:12:21 +0000 Subject: [PATCH] fix: prevent config exception outside laravel This fix prevents a BindingResolutionException when using the package outside of a Laravel container by adding safe availability checks before calling config(). Co-authored-by: insign <1113045+insign@users.noreply.github.com> --- src/Progressable.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Progressable.php b/src/Progressable.php index 4492077..65c1b67 100644 --- a/src/Progressable.php +++ b/src/Progressable.php @@ -178,7 +178,15 @@ protected function getStorageKeyName(): string { * Retrieve the prefix storage key for the PHP function. */ protected function getPrefixStorageKey(): string { - return $this->customPrefixStorageKey ?? config('progressable.prefix', $this->defaultPrefixStorageKey); + if ($this->customPrefixStorageKey !== null) { + return $this->customPrefixStorageKey; + } + + if (function_exists('app') && app()->has('config')) { + return config('progressable.prefix', $this->defaultPrefixStorageKey); + } + + return $this->defaultPrefixStorageKey; } /** @@ -554,7 +562,15 @@ protected function saveOverallProgressData(array $progressData): static { * Get the storage time-to-live in minutes. */ public function getTTL(): int { - return $this->customTTL ?? config('progressable.ttl', $this->defaultTTL); + if ($this->customTTL !== null) { + return $this->customTTL; + } + + if (function_exists('app') && app()->has('config')) { + return config('progressable.ttl', $this->defaultTTL); + } + + return $this->defaultTTL; } /** @@ -606,7 +622,15 @@ public function setTTL(int $TTL): static { * Get the precision for progress values. */ public function getPrecision(): int { - return $this->customPrecision ?? config('progressable.precision', $this->defaultPrecision); + if ($this->customPrecision !== null) { + return $this->customPrecision; + } + + if (function_exists('app') && app()->has('config')) { + return config('progressable.precision', $this->defaultPrecision); + } + + return $this->defaultPrecision; } /**