mardi 21 juillet 2020

Laravel -request fails mySQL update

The question is this: There is a table with forms in each row. Created with dataTables:

{
                        "data": null,
                        "targets": -1,
                        "defaultContent":
                            "<form action='start-data-submit'> <input  name=\"prod_barcode\" />"
                    },
                    {
                        "data": null,
                        "targets": -1,
                        "defaultContent":
                            " <input name=\"prod_quantity\"/>"
                    },
                  
                    {
                        "data": null,
                        "targets": -1,
                        "defaultContent":
                            " <input name=\"prod_price\" />"
                    },
                    {"data": "id", "visible": false, "searchable": false},
                    {"data": "updated_at", "visible": false, "searchable": false},
                    {
                        "data": null,
                        "defaultContent": " <button name=\"submit\" >Update</button> </form>"
                    },

on click in the form, the following is processed:


$('#start-data tbody').on('click', 'button', function () {//click update
                var row = $(this).closest('tr');


                var data = table.row(row).data().id;
                var info = table.row(row).$("input[name='prod_barcode']").val();
                var infoq = table.row(row).$("input[name='prod_quantity']").val();
                var infop = table.row(row).$("input[name='prod_price']").val();
                var url = "start-data-submit/" + "id=" + data + "&prod_barcode=" + info + "&prod_quantity=" + infoq + "&prod_price=" + infop + " ";
                $(location).attr('href', url);

route:

Route::get('start-data-submit/{id}&{prod_barcode}&{prod_quantity}&{prod_price}','StartDataController@update')

controller:

public function prodview(Request $request)
    {

        $timestamps = Carbon::today();;
        $prod_barcode = $request->route('prod_barcode');
        $prod_quantity = $request->route('prod_quantity');
        $prod_price = $request->route('prod_price');
        $uid = $request->route('id');

       
        DB::table('products')
            ->where('id', $uid)
            ->update(['updated_at' => $timestamps, 'prod_barcode' => $prod_barcode, 'prod_quantity' => $prod_quantity, 'prod_price' => $prod_price]);
}

It seems that everything is visible - the variables have the necessary values, but update does not happen, it does not give an error.


var_dump($timestamps,$prod_barcode,$prod_quantity,$prod_price,$uid);

issues:


object(Carbon\Carbon)#344 (3) { ["date"]=> string(26) "2020-07-17 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } string(14) "prod_barcode=2" string(15) "prod_quantity=4" string(13) "prod_price=78" string(7) "id=4680"

where else to dig? Any ideas would be very grateful.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire