Store method in Laravel with problem

0

I'm trying to implement a POST in this method:

 public function store(Request $request)
    {

       $veiculo = new Veiculo($request->(['marca', 'modelo', 'ano', 'preco']));
       $veiculo->save();
      return $this->respondCreated('The veiculo has been created');

    }

I'm finding that it's in trouble because it's returning me a 500 error in postman

{
    "marca": "Ford",
    "modelo": "Fusio",
    "ano": 2014,
    "preco": 137.985
}

    
asked by anonymous 30.10.2017 / 15:04

1 answer

0

The error it is reporting on line 30 is syntax.

Try using the format below:

$veiculo = new Veiculo();
$veiculo->marca = $request->input("marca");
$veiculo->modelo = $request->input("modelo");
$veiculo->ano = $request->input("ano");
$veiculo->preco = $request->input("preco");
$veiculo->save();
    
30.10.2017 / 21:44