Exemple #1
0
 public function actionCreateshop()
 {
     $model = new Shop();
     $data = json_decode(file_get_contents("php://input"));
     $model->ShopName = $data->ShopName;
     $model->Address1 = $data->Address1;
     $model->ContactNo = $data->ContactNo;
     $model->owner_name = $data->owner_name;
     $model->Logo = $data->Logo;
     $model->Slogan = $data->Slogan;
     $model->owner_id = $data->owner_id;
     $model->shop_type = $data->shop_type;
     $model->status = $data->status;
     //$model->created_at = date('Y-m-d');
     if ($model->save()) {
         $model2 = new Shopuser();
         $model2->username = $data->username;
         $model2->password = md5($data->password);
         $model2->shop_id = $model->shopid;
         $model2->emp_id = $data->owner_id;
         $model2->created_at = date('Y-m-d');
         $model2->status = '1';
         $model2->save();
         $response["status"] = 'success';
         $response["message"] = 'Product added successfully.';
         $response["data"] = (int) $model->shopid;
         http_response_code(200);
         header('Content-type: application/json');
         echo json_encode($response, JSON_NUMERIC_CHECK);
     } else {
         $response["status"] = 'error';
         $response["message"] = '';
         $response["error"] = $model->getErrors();
         header('Content-type: application/json');
         echo json_encode($response, JSON_NUMERIC_CHECK);
     }
 }