dimanche 20 août 2017

Laravel Query Builder Iteration

I have two tables "A" and "B". I need to do multiply all the column with integer values with table "B". How can I achieve that using Laravel Query Builders

$Agree =DB::table('agreements')->get();

foreach($Agree as $ag)
{
$th_name=$ag->theater_name;
$wk1_terms=$ag->wk1_terms;
$Aud=DB::table('Aud')->where('th','=',$th_name)->get();
foreach($Aud as $a){
    $wk1_aud=$a->wk1_aud;
    $result=$wk1_aud*$wk1_terms;
dd($result);
    }
}

If I execute the above code I get only the result of the first record from both the tables get multiplied.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire