dimanche 10 janvier 2016

Multiple array null value?

i try to insert mutiple arrays per job_id when i try this my array values out put as null value this is my store function

 $input = Input::all();
        $charge = Input::get('charge');
        $date = Input::get('date');
        $job = Input::get('job_id');
        $amount = Input::get('amount');
        $cat = Input::get('category');
        $id = \Auth::id();
        $data = array();
        foreach ($charge as $key=>$value ){
            $data[] = [
                'date' => $date,
                'charge'=>$key['charge'],
                'job_id'=>$job,
                'user_id'=>$id,
                'amount'=>$key['amount'],
                'category'=>$key['category'],
        ];
        }
        dd($data);

when i try to get out put i will get this out put

array:2 [▼
  0 => array:6 [▼
    "date" => "2016-01-10"
    "charge" => null
    "job_id" => "2"
    "user_id" => 1
    "amount" => null
    "category" => null
  ]
  1 => array:6 [▼
    "date" => "2016-01-10"
    "charge" => null
    "job_id" => "2"
    "user_id" => 1
    "amount" => null
    "category" => null
  ]
]

what i want is i want insert data to my database any one suggest me good idea ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire