Receive an array of objects in a php controller

Asked

Viewed 66 times

1

I want to send one array of objects for my controller PHP and I’ve done it this way

$http({
    method: 'POST',
    url: "payment/pagamento",
    data: $.param(vm.listProdsCar),
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
    }).success(function(response) {
        console.log(response);   

    }).error(function(response) {
        console.log(response);
    });

My array vm.listProdsCar that’s how it is:

inserir a descrição da imagem aqui

now I wanted to receive this array in the PHP controller like this:

public function postPayment(Request $request)
    {

foreach($request->all as $req){
echo '<script type="text/javascript">alert("'$req->name'");</script>';
  }
    }

But none of this is working, some dirt?

  • tried to put var_dump($request->all()); to see what you print?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.