title: how to make name unique if foreign key is same in laravel validate
body: <p>I have two tables &quot;rooms&quot; and &quot;beds&quot; i want to unique bed name when room_id is same. what should i do.</p>
  <pre><code>public function store(Request $request)
      {
          $roomid =  $request-&gt;input('room_id');
  
          //
          $attributes = request()-&gt;validate([
  
              'room_id' =&gt; ['required', 'integer', 'min:1'],
              'name' =&gt; ['required', 'string', 'min:1', 'max:10', 'unique:App\Models\bed,name,room_id' . $roomid],
              'type' =&gt; ['nullable', 'string', 'min:1', 'max:10'],
              'description' =&gt; ['nullable', 'string', 'min:1', 'max:20']
  
  
          ]);
          bed::create($attributes);
  }
  ~~~
  </code></pre>