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

rhand's avatar
Level 6

"No query results for model on trying to remove menu

When I try to remove a menu in our application I get

{
    "message": "No query results for model [App\Models\Editor\Project].",
    "exception": "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",
    "file": "/Users/user/code/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
    "line": 380,
    "trace": [
        {
            "file": "/Users/user/code/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
            "line": 356,
            "function": "prepareException",
            "class": "Illuminate\Foundation\Exceptions\Handler",
            "type": "->"
        },
        {
            "file": "/Users/user/code/domain.com/app/Exceptions/Handler.php",
            "line": 57,
            "function": "render",
            "class": "Illuminate\Foundation\Exceptions\Handler",
            "type": "->"
        },

So for some reason this model cannot load its data and I get a 404 running https://site.test/editor/delete-menu/55

That route loads this controller method:

...
public function deleteMenu(Menu $menu)
    {
        try {
            $menu->delete();

            return $this->respondWithSuccess(200, $menu->id);
        } catch (\Exception $e) {
            return $this->respondFailedWithError(500, $e->getMessage());
        }
    }
...

and also

remove(menu, event) {
          event.stopPropagation();
          axios.delete('/editor/delete-menu/' + menu.id)
              .then(this.handleRemove)
              .catch(this.catch);
      },

for JS way with resources/js/components/editor/sidebar/MenuList.vue. So this last Vue method was actually called failing on me..

Other odd thing is that menu 55 is still in the table menus... So a 404 makes no sense really.

0 likes
4 replies
Ben Taylor's avatar

Not sure if it's the issue, but in your deleteMenu function you are trying to access the Id of the model you just deleted.


            return $this->respondWithSuccess(200, $menu->id);

If you need to return the Id, save it as a variable before you delete the model. But your front end will already know the Id anyway, so not sure why you need to return it??

1 like
rhand's avatar
Level 6

@Ben Taylor Hmm, I need to think about all that as well. Thanks for the feedback.

rhand's avatar
rhand
OP
Best Answer
Level 6

Hmm, due to application project storage and load changes removal path with Axios seems to need

...
axios.delete('/editor/delete-menu/' + menu.id + `?project=${PROJECT_ID}`)
...

now. This so it can load const PROJECT_ID = {{ $project->id }} from blade template view.

Please or to participate in this conversation.