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

foxdevuz's avatar

apiResource is ignoring PUT, DELETE

I am using apiReource but I am getting this error whenever I try to delete using it:

  "message": "The DELETE method is not supported for route api/v1/admin/company. Supported methods: GET, HEAD, POST.",

and here's my files: api.php

Route::apiResource("/admin/company", AdminCompanyController::class)
    ->middleware("authAdmin");

AdminCompanyController

and app.php in bootstrap:

<?php

use App\Http\Middleware\AdminAuthMiddleware;
use App\Http\Middleware\CompanyAuthMiddleware;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
        then: function () {
            Route::middleware('api')
                ->prefix('api/v1')
                ->group(base_path('routes/api/v1/api.php'));
        }
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            "authAdmin"=>AdminAuthMiddleware::class,
            "authCompany"=>CompanyAuthMiddleware::class
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {

    })->create();

why am I getting this error while I am not using except() method in apiResource?

0 likes
9 replies
tykus's avatar

I would suspect that you are matching a different Route; is there any other URI that is similar, perhaps with a wildcard segment (/admin/{something})? If you have something like this, move it below your API Resource Route.

foxdevuz's avatar

@tykus yes I have here's whole api.php

<?php

use App\Http\Controllers\AdminCompanyController;
use App\Http\Controllers\AdminController;
use Illuminate\Support\Facades\Route;

Route::post("/admin/login", [AdminController::class, "login"]);

Route::apiResource("/admin/company", AdminCompanyController::class)
    ->middleware("authAdmin");

but I tried to put it below apiResource like this:

Route::apiResource("/admin/company", AdminCompanyController::class)
    ->middleware("authAdmin");

Route::post("/admin/login", [AdminController::class, "login"]);

but still got this error.

tykus's avatar

@foxdevuz the login Route would never have been the issue. Any chance that you have cached your routes; you should clear it if you did:

php artisan route:clear
foxdevuz's avatar

@tykus tried but no progress (

also tried:

  • deleting v1 logic in app.php
  • using Route::delete/put and all methods (same error)
  • clearing all caches
tykus's avatar
tykus
Best Answer
Level 104

@foxdevuz ok... thinking that maybe you don't have an ID for the DELETE or UPDATE actions; likely you have null where it should be an ID, so you DELETE or PUT to api/v1/admin/company, not api/v1/admin/company/{company}

Confirm please what URL is being used?

foxdevuz's avatar

@tykus it was my simple stupid mistake I am really sorry wasting your time and thank you for trying to answer!

foxdevuz's avatar

so I made a mistake while sending a request I should have send parameters in url not in form-data (Body) Thanks for @tykus for tying to help me!

foxdevuz's avatar

@tykus well... thanks! I also asked in another forum and they gave the answer and after it worked I came here and wrote it but didn't pay attention to your answer and they also gave the same answer with you, sorry bud) I edited and marked your answer as Correct. Hope you understand this and it won't make you mad that you stop answering to other.

Best wishes Thanks one more time :)

Please or to participate in this conversation.