-
Notifications
You must be signed in to change notification settings - Fork 1
Add make:data-provider command. #28
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
Conversation
Added support for Laravel Idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @hailwood, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
I've reviewed the pull request and here's a summary. This PR introduces a new make:data-provider
console command for Laravel applications, enhancing developer productivity by automating the creation of Inertia data providers. It also adds support for Laravel Idea, a popular IDE helper, by including a configuration file that defines code generation templates for Inertia data providers. This allows developers to quickly scaffold new data providers directly from their IDE.
Highlights
- New Artisan Command: Introduces
make:data-provider
artisan command to generate Inertia data providers. - Laravel Idea Support: Adds
ide.json
to provide code generation support for Inertia data providers within Laravel Idea.
Changelog
Click here to see the changelog
- ide.json
- Added a configuration file to support code generation for Inertia data providers in Laravel Idea.
- Defines a code generation template with the ID
webfox.create-inertia-data-provider
. - Specifies the class suffix as
DataProvider
. - Configures the file generation, including the app namespace (
Http\DataProviders
), file name pattern (${INPUT_CLASS|className|upperCamelCase}.php
), and stub template path (/stubs/inertia-data-provider.stub
). - Defines parameters for the stub template, including
class
andnamespace
.
- src/InertiaDataProviderMakeCommand.php
- Created a new
InertiaDataProviderMakeCommand
class extendingGeneratorCommand
. - Registers the command with the name
make:data-provider
. - Sets the command description to 'Create a new inertia data provider'.
- Overrides the
alreadyExists
method to check if the data provider already exists. - Overrides the
getStub
method to return the path to the stub file. - Implements the
resolveStubPath
method to resolve the fully-qualified path to the stub. - Overrides the
getDefaultNamespace
method to set the default namespace for the class torootNamespace.'\Http\DataProviders'
. - Overrides the
getOptions
method to define theforce
option.
- Created a new
- src/InertiaDataProvidersServiceProvider.php
- Registers the
InertiaDataProviderMakeCommand
with the Laravel console.
- Registers the
- stubs/inertia-data-provider.stub
- Creates a stub file for generating Inertia data providers.
- Defines the basic structure of a data provider class, including the namespace, class name, and constructor.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A command to create,
A provider of data's grace,
Inertia's swift flow.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new make:data-provider
console command for Laravel, enhancing developer experience by providing a convenient way to generate Inertia data providers. It also adds support for Laravel Idea, which is a welcome addition. The implementation appears to be well-structured and follows Laravel conventions.
Merge Readiness
The pull request introduces a useful feature and integrates well with the existing Laravel ecosystem. I recommend merging this pull request after addressing the review comments. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging.
protected function alreadyExists($rawName) | ||
{ | ||
return class_exists($rawName) || | ||
$this->files->exists($this->getPath($this->qualifyClass($rawName))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a more descriptive check to alreadyExists
. Currently, it only checks if the class exists or if the file exists. It might be beneficial to add a check to see if a data provider with the same name already exists in the specified namespace. This could prevent potential naming conflicts and improve the developer experience.
return class_exists($rawName) ||
$this->files->exists($this->getPath($this->qualifyClass($rawName)));
Introduced
make:data-provider
console command.Added support for Laravel Idea.