Answers for "save multiple data in laravel"

PHP
0

save multiple data in laravel

$head = Goodsreceiveheader::findorNew($request->id);
    $head->referencenumber=$request->referencenumber;
    $head->vendorid=$request->vendorid;
    $head->date=$request->date;
    $head->createdby=$request->createdby;
    if ($head->save()){
        $id = $head->id;
        foreach($request->itemid as $key =>$item_id){
            $data = array(
                            'goodsreceiveheader_id'=>$id,
                            'itemid'=>$request->itemid [$key],
                            'quantity'=>$request->quantity [$key],
                            'costprice'=>$request->costprice [$key],
                );
            Goodsreceivedetail::insert($data);
        }
    }

    Session::flash('message','You have successfully create goods receive.');

    return redirect('goodsreceive/goodsreceiveheader_list');
Posted by: Guest on November-06-2020
0

multe data on database laravel

$data = $request->all();
$finalArray = array();
foreach($data as $key=>$value){
   array_push($finalArray, array(
                'fltno'=>$value['sflt'],
                'model'=>$value['smodel'],
                'engine'=>$value['sengine'],
                'loc'=>$value['sloc'],
                'serviceType'=>$value['sstye'],
                'nextSvr'=> $value['snsvr'] )
   );
});

Model::insert($finalArray);
Posted by: Guest on October-29-2020

Code answers related to "save multiple data in laravel"

Browse Popular Code Answers by Language