我想根据输入的数量创建行

时间:2018-07-06 15:18:54

标签: php jquery laravel datatable

我想根据输入的数量创建行, 预期的结果:2 * 2 = 4 但我得到的结果是2 * 4 = 8

enter image description here

我的控制器代码:

 $input = Request::only('hidden_id_profil','hidden_profil_total','hidden_id_agent','hidden_id_agent_lundi','hidden_hr_lundi_de_agent', 'hidden_hr_lundi_a_agent',);

for ($i=0; $i < count($input['hidden_id_profil']); ++$i) 
{   
    for ($j=0; $j < count($input['hidden_id_agent_lundi'] ); ++$j) 
    {                   
        $new_details_planning_programme = new PlanningAdsAffecte();
        $new_details_planning_programme->id_planning_prestation = $id_planning_prestation;
        $new_details_planning_programme->id_profil = $input['hidden_id_profil'][$i];

        $new_details_planning_programme->lundi_heure_de = date('Y-m-d '.$input['hidden_hr_lundi_de_agent'][$j].':s');
        $new_details_planning_programme->lundi_heure_a = date('Y-m-d '.$input['hidden_hr_lundi_a_agent'][$j].':s');
        $new_details_planning_programme->lundi_id_agent = $input['hidden_id_agent_lundi'][$j] ;

        $new_details_planning_programme->save();
    }
}

0 个答案:

没有答案