-1

I am sending an entity to the database through a put request, but one of the variables is giving me trouble. I would like to know if there's a way to exclude a single variable from the request.

I am using axios for the db connection.

This is the entity being sent.

        $this->id = 0;
        $this->user = '';
        $this->type = '';
        $this->status = null;
        $this->signatureList = new ArrayCollection();

        //this is the array i want to exclude
        $this->amendmentList = new ArrayCollection();
        $this->draft = true;
        $this->archived = false;
        $this->canceled = false;
        $this->finished = false;
        $this->signed = false;
        $this->subject = null;
        $this->content = '';
        $this->createdAt = new \DateTime();
        parent::__construct();

This is the put request.

//it gets the entity through the id and sends it whole 
update: (id, data) => {
        window.httpMessage = { show: true, success: `Documento <b>#${id}</b> Atualizado`, error: "Documento <b>não Atualizado</b>" }
        return http.put(`/eletronic-documents/${id}`, data).then(res => res.data)
    }
Bruno Souza
  • 198
  • 1
  • 12
  • https://stackoverflow.com/a/41959141/4248328. assign them to a variable and then use `unset()` to unset whatever entity you want to delete – Alive to die - Anant Jul 01 '19 at 12:55
  • 3
    It would be helpful if you show the code that you're working with. The obvious answer to "exclude a single variable from the request" would be to simply _not include_ it. – Patrick Q Jul 01 '19 at 12:55
  • On the client side, you could use the `delete` operator to remove the entity from the axios request. Without code, we're unable to help further. – steadweb Jul 01 '19 at 13:01
  • You could use [array_filter()](https://www.php.net/manual/fr/function.array-filter.php). – Zenocode Jul 01 '19 at 13:06

1 Answers1

0

As suggested by user steadweb, a delete on the client side did the trick.

Bruno Souza
  • 198
  • 1
  • 12