Laravel Eloquent ORM WHERE IN (subquery)
<p>I've the following SQL query:</p>

<pre><code>SELECT * from db.tableA WHERE field in (SELECT id FROM db.tableB where other_field = value);
</code></pre>

<p>I want to select from tableA where field is in the array of values returned by the subquery. The question is: how can I do this with eloquent?
My current solution (which is very ugly I think) is the following:</p>

<pre><code>$a = \App\tableB::where("other_field", "=", $value)-&gt;select('id')-&gt;get();
$arr = array();
for ($i = 0; $i &lt; count($a); $i++) array_push($arr, $a[$i]['id']);
$res = \App\tableA::whereIn("field", $arr)-&gt;get();
</code></pre>

<p>There is a better way of doing this?</p>

<p>Thanks!</p>