AngularJS Laravel Pass范围,具有未知数量的变量到数据库

I'm creating an app using Laravel(API) and AngularJS. I have a store and cart using the library ng-cart. Every time I add an item to the cart, it adds to the cart object of an instance. In my database, I have three tables: item,orders,item_order. According to Laravel, I have to use the append command to append multiple items to an order on the item_order table. However, I do not know how many items I will send to the database.

My problem is, how do I pass an unknown number of variables from the scope to the database table item_order? Or more specifically, how to pass those variables from the front-end to API and how to handle that data on the API side?

Any ideas?

Simply you can pass them in a json object like this.

var object = {
    item: $scope.item,
    orders: $scope.orders,
    item_order :$scope.item_order
}

And you can access this object in you API

$object = json_decode(file_get_contents("php://input"), true);
$item = $object['item'];
$orders = $object['orders'];
$item_order = $object['orders']