title: Checking backed enum's scalar value in Laravel unique validation where clause
body: <p>In Laravel 9 with PHP 8.1, I can not compare backed enum in laravel validation rules where you can use -&gt;where clause. It needs a scalar value to compare. Are there any other ways to compare with an enum object rather than scalar value?</p>
  <pre><code>validator($attributes, [
      'manager_id' =&gt;
          [
              'required',
              'integer',
              Rule::exists(User::getTableName(), 'id'),
              Rule::unique(JProject::getTableName(), 'manager_id')
                  -&gt;where('status', JProjectStatus::Active)
          ]
  ])-&gt;validate();
  </code></pre>
  <p><strong>JProjectStatus is a backed enum</strong></p>
  <pre><code>enum JProjectStatus: string
  {
      case Active = 'active';
      case Inactive = 'inactive';
      case Blocked = 'blocked';
  }
  </code></pre>
  <p>When I'm trying to check the manager is unique where the project is active or not, I encountered a type error and I totally understand that it is comparing <em>string</em> with <em>enum object</em>.</p>
  <blockquote>
  <p>message   &quot;str_replace(): Argument #3 ($subject) must be of type
  array|string, App\Enums\JProjectStatus given&quot; exception &quot;TypeError&quot;</p>
  </blockquote>
  <p>But if I write like below which is a scaler value that's totally fine with str_replate().</p>
  <pre><code>validator($attributes, [
  'manager_id' =&gt; 
  [
    'required', 
    'integer', 
    Rule::exists(User::getTableName(), 'id'),
    Rule::unique(JProject::getTableName(), 'manager_id')-&gt;where('status', JProjectStatus::Active-&gt;value)
  ]
  
  ])-&gt;validate();
  </code></pre>
  <p>Because now <strong>'JProjectStatus::Active-&gt;value'</strong> is a scalar value of <em>'active'</em></p>
  <p>Sure, I can pass a closure in where condition but want to know the best practice. My question is, Is it okay to write like this, or is there any other way to write best practice with enum object.</p>