---
title: "Equality checks — Enums for Laravel | Roundly"
description: "is(), isNot(), isIn() and isNotIn() compare cases by identity — readable conditions without manual === chains."
url: https://roundly-consulting.com/open-source/docs/enums-for-laravel/comparisons
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Enums for Laravel](https://roundly-consulting.com/open-source/docs/enums-for-laravel.md)

# Equality checks

Compare a case against one or several others in readable code:

```php
$category = NewsCategory::HotNews;

$category->is(NewsCategory::HotNews);    // true
$category->isNot(NewsCategory::HotNews); // false

$category->isIn([NewsCategory::HotNews, NewsCategory::RegularNews]);        // true
$category->isNotIn([NewsCategory::RegularNews, NewsCategory::PrivateNews]); // true
```

Comparisons are identity checks (===). is() and isNot() are typed to the enum itself, and isIn() / isNotIn() take a list of cases — an array of raw values never matches. Resolve raw input to a case first with from(), tryFromName() or tryFromLabel():

```php
$category->isIn(['hot-news']);                       // false — raw values never match
$category->isIn([NewsCategory::from('hot-news')]);   // true
```

## In practice

Filter a collection of models by category:

```php
$public = [NewsCategory::HotNews, NewsCategory::RegularNews];

$articles = Article::query()->latest()->get()
    ->filter(fn (Article $article): bool => $article->category->isIn($public));
```

Or keep a policy readable:

```php
use App\Enums\NewsCategory;
use App\Models\Article;
use App\Models\User;

final class ArticlePolicy
{
    public function view(?User $user, Article $article): bool
    {
        return $user !== null || $article->category->isNot(NewsCategory::PrivateNews);
    }
}
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/enums-for-laravel.md)
