How to store values from a query result into a column with a nested foreach
<p>Hi I am trying to store some values in a column using a query result with nested <code>foreach</code> something like this: </p>

<pre><code>if ($migrate_centers) {
    $centersdt = $otf-&gt;getTable('centdt');
    $centersdt = $centersdt-&gt;get();
    $regions = $otf-&gt;getTable('ldt');
    //$regions = $regions-&gt;get();
    $regionsList = array();
    $result = array();

    try {
        $regions = $regions-&gt;select('ldt.lname')-&gt;leftJoin('centdt', 'ldt.lid', '=', 'centdt.centregion')-&gt;groupBy('centdt.centregion')-&gt;get();

        foreach($centersdt as $center) {

            $center4 = new Center;
            $center4-&gt;code = $center-&gt;centid;
            $center4-&gt;phone = $center-&gt;centphone;
            $center4-&gt;email = $center-&gt;centemail;
            $center4-&gt;region_id = $center-&gt;centregion;
            $center4-&gt;name = $Arabic-&gt;convert($center-&gt;centname);
            foreach($regions as $reg) {
                $center4-&gt;region = $Arabic-&gt;convert($reg-&gt;lname);
            }
            $center4-&gt;save();
        }




    } catch (Illuminate\Database\QueryException $e) {
        return $e;
    }
}
</code></pre>

<p>But I get only same value  in all rows </p>