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

Windows incompatibility due to namespaced model in model:show #37

Closed
vintagesucks opened this issue May 29, 2024 · 2 comments · Fixed by #38
Closed

Windows incompatibility due to namespaced model in model:show #37

vintagesucks opened this issue May 29, 2024 · 2 comments · Fixed by #38
Assignees
Labels
bug Something isn't working

Comments

@vintagesucks
Copy link

const modelShowCommand = `php artisan model:show ${namespacedModel} --json`;

Hi, when I tried this package I noticed that type generation failed on Windows, but worked on macOS.


php artisan model:show App\\Models\\User --json (current format)

  • macOS: works
  • Windows: error
◐ [Model] Running 'php artisan model:show App\\Models\\User --json'                                                                                                                                                          17:40:40  
PHP Fatal error:  Cannot declare class App\Models\User, because the name is already in use in app\Models\User.php on line 12
[17:40:42] ℹ [Model] Failed to get model data for User'. You still can generate types by running php artisan model:show App\\Models\\User --json manually and then run 'laravel-typegen' with SKIP_ARTISAN_COMMAND=true environment variable.

 ERROR  [Model] Command failed: php artisan model:show App\\Models\\User --json                                                                                                                                              17:40:42  
PHP Fatal error:  Cannot declare class App\Models\User, because the name is already in use in app\Models\User.php on line 12

php artisan model:show App/Models/User --json

  • macOS: works
  • Windows: works
@7nohe 7nohe added the bug Something isn't working label Jun 9, 2024
@7nohe
Copy link
Owner

7nohe commented Jun 9, 2024

@vintagesucks Thank you for reporting the issue. I have fixed it in #38. Could you please specify the branch as below and check if the issue has been resolved?

package.json:

{
  "devDependencies": {
        "@7nohe/laravel-typegen": "github:7nohe/laravel-typegen#fix/namespaced-models-for-windows",
  }
}

@7nohe 7nohe self-assigned this Jun 9, 2024
@vintagesucks
Copy link
Author

@7nohe Thank you for looking into this.

Yarn wouldn't let me specify the branch in that format without errors, but after I manually applied the changes from #38 to generate.js and utils.js via yarn patch, it worked on both Windows and macOS! 🚀

@7nohe 7nohe closed this as completed in #38 Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants