File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change 55use Bavix \Wallet \Objects \EmptyLock ;
66use Illuminate \Contracts \Cache \Lock ;
77use Illuminate \Contracts \Cache \LockProvider ;
8+ use Illuminate \Contracts \Cache \Store ;
89use Illuminate \Database \Eloquent \Model ;
910use Illuminate \Support \Facades \Cache ;
1011use Illuminate \Support \Str ;
@@ -51,6 +52,18 @@ protected function bindTo($self, \Closure $closure): \Closure
5152 }
5253 }
5354
55+ /**
56+ * @return Store|null
57+ */
58+ protected function cache (): ?Store
59+ {
60+ try {
61+ return Cache::getStore ();
62+ } catch (\Throwable $ throwable ) {
63+ return null ;
64+ }
65+ }
66+
5467 /**
5568 * @param object $self
5669 * @param string $name
@@ -59,19 +72,8 @@ protected function bindTo($self, \Closure $closure): \Closure
5972 */
6073 protected function lockProvider ($ self , string $ name , int $ seconds ): Lock
6174 {
62- try {
63- /**
64- * @var LockProvider $store
65- */
66- $ store = Cache::getStore ();
67- } catch (\Throwable $ throwable ) {
68- // todo: write error's
69- }
70-
71- $ enabled = false ;
72- if (isset ($ store )) {
73- $ enabled = config ('wallet.lock.enabled ' , false );
74- }
75+ $ store = $ this ->cache ();
76+ $ enabled = $ store && config ('wallet.lock.enabled ' , false );
7577
7678 if ($ enabled && $ store instanceof LockProvider) {
7779 $ class = \get_class ($ self );
You can’t perform that action at this time.
0 commit comments