Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

xsmalbil@icloud.com's avatar

Resource route's Destroy is not getting called on production

Hello everybody,

I was hoping that somebody could walk me towards an answer. Cause I am getting no bright ideas.

My problem is: Deleting something works LOCAL, but on production it does not delete, but does gives a 200 http code back.

Where should I start looking? I assume it has to do with the server configuration, I'm not sure. Cause like I said: It works on all our developer vagrant boxes, but on the shared hosting of the customer...it just seems to not delete it.

routes.php

        resource('activities', 'ActivityApiController',     ['except' => ['create', 'edit']]);

ActivityApiController.php


    /**
     * Remove a model from the collection.
     *
     * @param $id
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function destroy($id)
    {
        $model = $this->repository->show($id);

        if ($this->isNotFound($model)) {
            return $this->respondNotFound();
        }

        $model->delete();

        return $this->respondNoContent();
    }

0 likes
3 replies
clevonnoel's avatar

I would like to know what $model = $this->repository->show($id); does and return;

In the meanwhile:

I understand that you building out a Rest API, and it could mean that the show method is bring back a json. The $model->delete() function won't work.

You may need to do this on your destroy method

public function destroy($id)
{
    $model = Activity::find($id);
    if($model->exists)
    {
        return $this->respondNotFound();
    }
    $model->delete();
    return $this->respondNoContent();
}
xsmalbil@icloud.com's avatar

@clevonnoel

Thanks for taking your time trying to answer the question.

The following code:

$model = $this->repository->show($id);

returns an entity from the repository. In this case a sql database.

On my local machine(development environment), I can run:

    public function destroy($id)
    {
        $model = $this->repository->show($id);

        if ($this->isNotFound($model)) {
            return $this->respondNotFound();
        }

        $model->delete();

        return $this->respondNoContent();
    }

..and it actually deletes my entity.

The problem on occurs on the shared hosting platform that is used for production.

It seems that my resource route it's destroy never get's called on the production environment. To be clear: the route does get called on the development environment

xsmalbil@icloud.com's avatar
Level 12

Alright.. I have no SSH access and can not go down the whole stack. So I changed the routes to do a delete on a POST. This works, but I still would like to know why a resource route's destroy method does not get called.

Please or to participate in this conversation.