如何将自动生成的输入传递给 laravel 中的 api 函数
我有一个网络系统,输入字段会自动生成并保存在数据库中。我想将输入数据推送到 API 函数,并且能够推送一些输入。我有自动生成的输入字段,但无法推送它这是生成它的代码。
$SystemID = new SystemID('product');
//the new SystemID('product'); autogenerates the the systemid which is saved in the product table
$product = new product();
$product->systemid = $SystemID;
$product->save();
我已经在控制器的 api 函数中尝试过此代码,但它显示错误 systemid 不能为 null
$productdetails=new Product;
$productdetails->systemid =$request->systemid;
我也有一个 SystemID 类其他 API 端点 Web 系统。 如何将自动生成的 systemid 传递给 api 中的控制器?
on dd(系统ID);我明白了
-type: "03"
-id: 1509
-invalid: false
-allowed_type: array:52 [
"company" => array:2 [
0 => "company_seq"
1 => "01"
]
"individual" => array:2 [
0 => "individual_seq"
1 => "02"
]
"product" => array:2 [
0 => "product_seq"
1 => "03"
]
"location" => array:2 [
0 => "location_seq"
1 => "04"
]
"terminal" => array:2 [
0 => "terminal_seq"
1 => "05"
]
"counter" => array:2 [
0 => "counter_seq"
1 => "07"
]
"voucherlist" => array:2 [
0 => "voucher_seq"
1 => "08"
]
"takeaway" => array:2 [
0 => "takeaway_seq"
1 => "09"
]
"stockreport" => array:2 [
0 => "stockreport_seq"
1 => "11"
]
"wastage" => array:2 [
0 => "wastage_seq"
1 => "12"
]
"rack" => array:2 [
0 => "rack_seq"
1 => "13"
]
"promo" => array:2 [
0 => "promo_seq"
1 => "14"
]
"member" => array:2 [
0 => "member_seq"
1 => "15"
]
"loyaltypts" => array:2 [
0 => "loyaltypts_seq"
1 => "16"
]
"membershipmts" => array:2 [
0 => "membershipmts_seq"
1 => "17"
]
"franchise" => array:2 [
0 => "franchise_seq"
1 => "18"
]
"og_tank" => array:2 [
0 => "ogtank_seq"
1 => "19"
]
"calibration" => array:2 [
0 => "calibration_seq"
1 => "20"
]
"controller" => array:2 [
0 => "controller_seq"
1 => "21"
]
"pump" => array:2 [
0 => "pump_seq"
1 => "22"
]
"invoice" => array:2 [
0 => "invoice_seq"
1 => "23"
]
"salesorder" => array:2 [
0 => "salesorder_seq"
1 => "24"
]
"trackingreport" => array:2 [
0 => "trackingreport_seq"
1 => "25"
]
"stocktake" => array:2 [
0 => "stocktake_seq"
1 => "26"
]
"refund" => array:2 [
0 => "refund_seq"
1 => "27"
]
"cmr" => array:2 [
0 => "cmr_seq"
1 => "28"
]
"platform" => array:2 [
0 => "platform_seq"
1 => "29"
]
"creditnote" => array:2 [
0 => "creditnote_seq"
1 => "30"
]
"debitnote" => array:2 [
0 => "debitnote_seq"
1 => "31"
]
"agent" => array:2 [
0 => "agent_seq"
1 => "32"
]
"comm_company" => array:2 [
0 => "comm_company_seq"
1 => "32"
]
"pts_prd_redemption" => array:2 [
0 => "pts_prd_redemption_seq"
1 => "33"
]
"ec_buyer" => array:2 [
0 => "ec_buyer_seq"
1 => "34"
]
"ec_merchant" => array:2 [
0 => "ec_merchant_seq"
1 => "35"
]
"ec_receipt" => array:2 [
0 => "ec_receipt_seq"
1 => "36"
]
"csr" => array:2 [
0 => "csr_seq"
1 => "37"
]
"cpcr" => array:2 [
0 => "cpcr_seq"
1 => "38"
]
"projmgmt" => array:2 [
0 => "projmgmt_seq"
1 => "39"
]
"projmgmt_job" => array:2 [
0 => "projmgmtjob_seq"
1 => "40"
]
"asset" => array:2 [
0 => "asset_seq"
1 => "47"
]
"hcap_staff" => array:2 [
0 => "hcap_staff_seq"
1 => "42"
]
"pjobproduct" => array:2 [
0 => "pjobproduct_seq"
1 => "43"
]
"ext_stockreport" => array:2 [
0 => "ext_stockreport_seq"
1 => "44"
]
"purchaseorder" => array:2 [
0 => "purchaseorder_seq"
1 => "45"
]
"deliveryorder" => array:2 [
0 => "deliveryorder_seq"
1 => "46"
]
"vehicle" => array:2 [
0 => "vehicle_seq"
1 => "48"
]
"atg" => array:2 [
0 => "atg_seq"
1 => "49"
]
"converter" => array:2 [
0 => "converter_seq"
1 => "50"
]
"converterport" => array:2 [
0 => "converterport_seq"
1 => "51"
]
"arpayment" => array:2 [
0 => "arpayment_seq"
1 => "52"
]
"carparklot" => array:2 [
0 => "carparklot_seq"
1 => "54"
]
"authorize" => array:2 [
0 => "authorize_seq"
1 => "55"
]
]
-global_platform: 1
}```
i have a web system whereby the input fields are autogenerated and saved in the database.i want to push the input data to an api function and have been able to push some of the inputs.i have which is autogenerated but am unable to push it.its the systemid.here is the code that generates it
$SystemID = new SystemID('product');
//the new SystemID('product'); autogenerates the the systemid which is saved in the product table
$product = new product();
$product->systemid = $SystemID;
$product->save();
i have tried this code in the api function of the controller but it shows an error systemid cannot be null
$productdetails=new Product;
$productdetails->systemid =$request->systemid;
also i have a SystemID class in the in the other apiendpoint web system.
how can i pass the autogenerated systemid to the controller in the api?
on dd(SystemID); i get this
-type: "03"
-id: 1509
-invalid: false
-allowed_type: array:52 [
"company" => array:2 [
0 => "company_seq"
1 => "01"
]
"individual" => array:2 [
0 => "individual_seq"
1 => "02"
]
"product" => array:2 [
0 => "product_seq"
1 => "03"
]
"location" => array:2 [
0 => "location_seq"
1 => "04"
]
"terminal" => array:2 [
0 => "terminal_seq"
1 => "05"
]
"counter" => array:2 [
0 => "counter_seq"
1 => "07"
]
"voucherlist" => array:2 [
0 => "voucher_seq"
1 => "08"
]
"takeaway" => array:2 [
0 => "takeaway_seq"
1 => "09"
]
"stockreport" => array:2 [
0 => "stockreport_seq"
1 => "11"
]
"wastage" => array:2 [
0 => "wastage_seq"
1 => "12"
]
"rack" => array:2 [
0 => "rack_seq"
1 => "13"
]
"promo" => array:2 [
0 => "promo_seq"
1 => "14"
]
"member" => array:2 [
0 => "member_seq"
1 => "15"
]
"loyaltypts" => array:2 [
0 => "loyaltypts_seq"
1 => "16"
]
"membershipmts" => array:2 [
0 => "membershipmts_seq"
1 => "17"
]
"franchise" => array:2 [
0 => "franchise_seq"
1 => "18"
]
"og_tank" => array:2 [
0 => "ogtank_seq"
1 => "19"
]
"calibration" => array:2 [
0 => "calibration_seq"
1 => "20"
]
"controller" => array:2 [
0 => "controller_seq"
1 => "21"
]
"pump" => array:2 [
0 => "pump_seq"
1 => "22"
]
"invoice" => array:2 [
0 => "invoice_seq"
1 => "23"
]
"salesorder" => array:2 [
0 => "salesorder_seq"
1 => "24"
]
"trackingreport" => array:2 [
0 => "trackingreport_seq"
1 => "25"
]
"stocktake" => array:2 [
0 => "stocktake_seq"
1 => "26"
]
"refund" => array:2 [
0 => "refund_seq"
1 => "27"
]
"cmr" => array:2 [
0 => "cmr_seq"
1 => "28"
]
"platform" => array:2 [
0 => "platform_seq"
1 => "29"
]
"creditnote" => array:2 [
0 => "creditnote_seq"
1 => "30"
]
"debitnote" => array:2 [
0 => "debitnote_seq"
1 => "31"
]
"agent" => array:2 [
0 => "agent_seq"
1 => "32"
]
"comm_company" => array:2 [
0 => "comm_company_seq"
1 => "32"
]
"pts_prd_redemption" => array:2 [
0 => "pts_prd_redemption_seq"
1 => "33"
]
"ec_buyer" => array:2 [
0 => "ec_buyer_seq"
1 => "34"
]
"ec_merchant" => array:2 [
0 => "ec_merchant_seq"
1 => "35"
]
"ec_receipt" => array:2 [
0 => "ec_receipt_seq"
1 => "36"
]
"csr" => array:2 [
0 => "csr_seq"
1 => "37"
]
"cpcr" => array:2 [
0 => "cpcr_seq"
1 => "38"
]
"projmgmt" => array:2 [
0 => "projmgmt_seq"
1 => "39"
]
"projmgmt_job" => array:2 [
0 => "projmgmtjob_seq"
1 => "40"
]
"asset" => array:2 [
0 => "asset_seq"
1 => "47"
]
"hcap_staff" => array:2 [
0 => "hcap_staff_seq"
1 => "42"
]
"pjobproduct" => array:2 [
0 => "pjobproduct_seq"
1 => "43"
]
"ext_stockreport" => array:2 [
0 => "ext_stockreport_seq"
1 => "44"
]
"purchaseorder" => array:2 [
0 => "purchaseorder_seq"
1 => "45"
]
"deliveryorder" => array:2 [
0 => "deliveryorder_seq"
1 => "46"
]
"vehicle" => array:2 [
0 => "vehicle_seq"
1 => "48"
]
"atg" => array:2 [
0 => "atg_seq"
1 => "49"
]
"converter" => array:2 [
0 => "converter_seq"
1 => "50"
]
"converterport" => array:2 [
0 => "converterport_seq"
1 => "51"
]
"arpayment" => array:2 [
0 => "arpayment_seq"
1 => "52"
]
"carparklot" => array:2 [
0 => "carparklot_seq"
1 => "54"
]
"authorize" => array:2 [
0 => "authorize_seq"
1 => "55"
]
]
-global_platform: 1
}```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你必须先保存SystemID,这里你只创建了一个对象SystemID,所以它没有id。
You have to save the SystemID first, here you only created an object SystemID so it doesn't have an id.