mercredi 17 janvier 2018

How can I show data stored in a database with ajax - laravel?

My route as below;

Route::post ('/sepetim', 'ShoppingCartController@addStock');

My controller as below;

 public function  addStock(Request $request) {
        $data = new ShoppingCartDetail();
        $data->cart_id = $request->input('cart_id');
        $data->stock_id = $request->input('stock_id');
        $data->price = 1;
        $data->save();
    }

My ajax as below;

$.ajax({
                    type: 'POST',
                    url: '/sepetim',
                    data: {
                        '_token': $('input[name="_token"]').val(),
                        'name': $('input[name=name]').val(),
                        'cart_id': $('input[name=cart_id]').val(),
                        'stock_id': id
                    },
                    success: function(data) {
                       // alert("Başarılı bir şekilde eklendi.");
                    },
                });

the above code is registering to the database.

my question. How can I extract the data stored in the database?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2EQQeJx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire