如何将这个Slim Framework代码转换为Laravel 5.2

时间:2016-06-11 13:13:57

标签: php laravel-5.2 slim

//这会将插入到db。中的两个表中。

$app->post('/create_order', 'authenticate', function() use($app) { 
    // check for required params

    verifyRequiredParams(array('oder_data')); 
    global $user_id;
    $oder_data = $app->request->post('oder_data');

    $db = new DbHandler();
    $id_client=$user_id;
    $response = array();

    //parsing a json array
    $json_a=json_decode($oder_data,true);
    if (!$json_a=="") {

        $order_type=$json_a["order_type"];

        $id_reservation=$json_a["id_reservation"];

        $id_order = $db->createOrder($id_client, $order_type, $id_reservation); 

        $hh=$json_a['data'];

         foreach($json_a['data'] as $p)
            { 
                $id_dish=$p['id_dish']; 
                $amount=$p['amount'];
                $description=$p['description']; 
                $note=$p['note'];

                $result = $db->insert_order_items($id_order, $id_dish, $amount, $description, $note); 

            } 
            return true;

0 个答案:

没有答案