jeudi 27 avril 2017

Laravel Eloquent: destroy route with id but model->exists false

i'm making a delete call with ajax to my destroy route for a model. Everything works, except that the controller doesn't match the corresponding record in the database.

I call a api/serviceoperations/17 ajax delete call, but if i place a var_dump in my controller in this way:

    public function destroy(ServiceOperation $serviceOperation) {
        var_dump($serviceOperation);die;
    }

i get an empty model that doesn't exists

 public 'exists' => boolean false

Of course I have a model called ServiceOperation that refers to the table service_operations, with the primary key id, and in my database there's a record with key 17.

Why doesn't the controller resolves my id the route to the relative record in the db?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire