PHPackages                             kurozora/laravel-cooldown - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kurozora/laravel-cooldown

ActiveLibrary

kurozora/laravel-cooldown
=========================

Easily implement global or model-specific cooldowns into your Laravel app.

1.0(6y ago)202801MITPHPPHP ^7.3CI failing

Since Apr 28Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Kurozora/laravel-cooldown)[ Packagist](https://packagist.org/packages/kurozora/laravel-cooldown)[ Docs](https://github.com/Kurozora/laravel-cooldown)[ RSS](/packages/kurozora-laravel-cooldown/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

[![](.github/icon.png)](.github/icon.png)

[![Latest version on packagist](https://camo.githubusercontent.com/4666beba44be270bbb75dbbbc43da9d2aeb27b61843b7c58ab2c0512b5c1eca2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b75726f7a6f72612f6c61726176656c2d636f6f6c646f776e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kurozora/laravel-cooldown)[![GitHub Tests Action Status](https://camo.githubusercontent.com/56758afa3d12d60ae5b563437757bb9217b5e300a7bd3a76413221995f24de8a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b75726f7a6f72612f6c61726176656c2d636f6f6c646f776e2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/kurozora/laravel-cooldown/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Quality score](https://camo.githubusercontent.com/b43e622364e2a671a00fc2a3281b29579785b306247185caae695556e8486724/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6b75726f7a6f72612f6c61726176656c2d636f6f6c646f776e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/kurozora/laravel-cooldown)[![Total downloads](https://camo.githubusercontent.com/56c350422254569aa36143eb48cca42b475dddaee6ab7e91919499eb7ebf1ddc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b75726f7a6f72612f6c61726176656c2d636f6f6c646f776e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kurozora/laravel-cooldown)[![Kurozora Open Source](.github/kurozora-open-source-badge.svg)](https://developer.kurozora.app)

 *plug-and-play global and model-specific cooldowns*

Laravel Cooldowns
=================

[](#laravel-cooldowns)

This Laravel package makes it easier to implement cooldowns into your app.
Consider the following example:

```
// The user will be able to post again 5 minutes from now
$user->cooldown('create-post')->for('5 minutes');
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require kurozora/laravel-cooldown
```

Usage
-----

[](#usage)

### Global cooldowns

[](#global-cooldowns)

Global cooldowns aren't tied to any model and are the same throughout your entire app.
Use the `cooldown` helper to create one:

```
cooldown('registration')->for('1 hour');
```

Here's an example of how you could limit registration to once per hour:

```
if(cooldown('registration')->notPassed())
    return 'Registration is currently unavailable.';

// ... perform account registration ...

cooldown('registration')->for('1 hour');
```

### Model-specific cooldowns

[](#model-specific-cooldowns)

Of course, a more useful use-case would be to tie cooldowns to models. In order to make use of this, you'll need to add the trait to your model:

```
use Illuminate\Database\Eloquent\Model;
use Kurozora\Cooldown\HasCooldowns;

class User extends Model
{
    use HasCooldowns;
}
```

The API used to interact with model-specific cooldowns is the exact same as global cooldowns, however you use the `cooldown` method on the model itself:

```
if($user->cooldown('create-post')->notPassed())
    return 'You cannot create a post right now.';

// ... create the post ...

$user->cooldown('create-post')->for('5 minutes');
```

### All cooldown methods

[](#all-cooldown-methods)

These methods are available for both global and model-specific cooldowns.

`for()` **Cooldown for a timespan**
Pass along a string with the desired timespan.

```
cooldown('create-post')->for('1 day 3 hours');
```

`until()` **Cooldown for a given datetime**
Pass along a Carbon object with the desired datetime.

```
$tomorrow = now()->addDay();

cooldown('create-post')->until($tomorrow);
```

`reset()` **Reset the cooldown**
The cooldown will be reset, and the action will be available immediately.

```
cooldown('create-post')->reset();
```

`passed()`
Checks whether the cooldown has passed. Returns true if the cooldown hasn't ever been initiated.

```
cooldown('create-post')->passed(); // true/false
```

`notPassed()`
Checks whether the cooldown is still active, and thus hasn't passed yet.

```
cooldown('create-post')->notPassed(); // true/false
```

`expiresAt()` **Get the expiration date**
Returns the datetime at which the cooldown will pass.

```
cooldown('create-post')->expiresAt(); // Illuminate\Support\Carbon object
```

`get()`
Returns the underlying Cooldown model.

```
cooldown('create-post')->get(); // Kurozora\Cooldown\Models\Cooldown object
```

### Testing

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Contributors ✨
--------------

[](#contributors-)

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

  [![](https://avatars1.githubusercontent.com/u/21341801?v=4)
**Musa**](http://musa11971.me)
[💻](https://github.com/Kurozora/laravel-cooldown/commits?author=musa11971 "Code") [📖](https://github.com/Kurozora/laravel-cooldown/commits?author=musa11971 "Documentation") [![](https://avatars0.githubusercontent.com/u/6556281?v=4)
**Kirito**](https://www.linkedin.com/in/katklian/)
[🤔](#ideas-kiritokatklian "Ideas, Planning, & Feedback") [🎨](#design-kiritokatklian "Design") This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2205d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c3104e44e9879242659fa0c6717fa6d01be9fcbb90a33d0c49c1ea1c6348332?d=identicon)[musa11971](/maintainers/musa11971)

---

Top Contributors

[![musa11971](https://avatars.githubusercontent.com/u/21341801?v=4)](https://github.com/musa11971 "musa11971 (13 commits)")[![allcontributors[bot]](https://avatars.githubusercontent.com/in/23186?v=4)](https://github.com/allcontributors[bot] "allcontributors[bot] (6 commits)")

---

Tags

laravellaravel-packagelaravel-cooldown

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kurozora-laravel-cooldown/health.svg)

```
[![Health](https://phpackages.com/badges/kurozora-laravel-cooldown/health.svg)](https://phpackages.com/packages/kurozora-laravel-cooldown)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
