diff --git a/src/Illuminate/Queue/Middleware/RateLimited.php b/src/Illuminate/Queue/Middleware/RateLimited.php index efb0f60841f2..f7a8d6c08105 100644 --- a/src/Illuminate/Queue/Middleware/RateLimited.php +++ b/src/Illuminate/Queue/Middleware/RateLimited.php @@ -120,4 +120,31 @@ protected function getTimeUntilNextRetry($key) { return $this->limiter->availableIn($key) + 3; } + + /** + * Prepare the object for serialization. + * + * @return array + */ + public function __serialize() + { + return [ + 'limiterName' => $this->limiterName, + 'shouldRelease' => $this->shouldRelease, + ]; + } + + /** + * Prepare the object after unserialization. + * + * @param array $data + * @return void + */ + public function __unserialize(array $data) + { + $this->limiter = Container::getInstance()->make(RateLimiter::class); + + $this->limitedName = $data['limiterName']; + $this->shouldRelease = $data['shouldRelease']; + } }