Skip to content

Generated resource: incorrect class/namespace #53

@sneakylenny

Description

@sneakylenny

Laravel Rest Api Version

1.1

Laravel Version

10.10

PHP Version

8.2

Database Driver & Version

MySQL 8.1.0 on Windows 10 Pro (x64)

Description

When generating a resource using the php artisan rest:resource {name} command it will generate a resource class but generates the actions and instructions methods with an incorrectly namespaced class. This class is not used/imported into the resource class by default, which results in an Exception and intelisense errors:

image

What it should look like:

image

To fix this I can see 2 possible solutions:

  1. Fix the classes on the actions and instructions methods to include the full class path.
  2. Import the class into the file (use \Lomkit\Rest\Http\Requests\RestRequest;) and remove the full path from the other methods.

I noticed you prefer to include the complete path so I may create a PR applying solution 1 if allowed.

Steps To Reproduce

  1. Install lomkit/laravel-rest-api^1.1
  2. Run command php artisan rest:resource TestResource
  3. Inspect the generated file, should be located at {projectroot}/app/Rest/Resources/TestResource.php
  4. Scroll down to the actions and instructions methods and see the incorrect result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions