Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controller.destroy.stub: wrong returntype of function __invoke(...) #7

Open
eltoro0815 opened this issue Mar 26, 2023 · 0 comments
Open

Comments

@eltoro0815
Copy link

JsonResource has to be JsonResponse in generated files with the pattern [ModelName]DestroyController.php

Therefor JsonResource should be JsonResponse in file ./stubs/controller.destroy.stub

WRONG (current version):

<?php

declare(strict_types=1);

namespace {{ namespace }};

use App\Enums\Version;
use {{ namespacedModel }};
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Symfony\Component\HttpFoundation\Response;

final class {{ class }} extends Controller
{
    public function __invoke(Request $request, Version $version, {{ model }} ${{ modelVariable }}): JsonResource
    {
//        abort_unless(
//            $version->greaterThanOrEqualsTo(Version::v1_0),
//            Response::HTTP_NOT_FOUND
//        );

        {{ model }}->delete();

        return response()->json([], Response::HTTP_NO_CONTENT);
    }
}

WRIGHT:

<?php

declare(strict_types=1);

namespace {{ namespace }};

use App\Enums\Version;
use {{ namespacedModel }};
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Symfony\Component\HttpFoundation\Response;

final class {{ class }} extends Controller
{
    public function __invoke(Request $request, Version $version, {{ model }} ${{ modelVariable }}): JsonResponse
    {
//        abort_unless(
//            $version->greaterThanOrEqualsTo(Version::v1_0),
//            Response::HTTP_NOT_FOUND
//        );

        {{ model }}->delete();

        return response()->json([], Response::HTTP_NO_CONTENT);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant