Create PowerGrid Components in different directories following Livewire Class Namespace #1501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
⚡ PowerGrid - Pull Request
Welcome and thank you for your interest in contributing to our project!. You must use this template to submit a Pull Request or it will not be accepted.
Motivation
Description
This pull request improves the compatibility with Livewire Class Namespace configuration, allowing to create PowerGrid tables outside the
app/Models
directory.To illustrate a use case, let's see an example where the application is organized in a Domain-Driven Design. Here is the directory structure:
By default, PowerGrid auto discovers Models living in the directory
app/Models/
. This PR, presents the new configuration keylivewire-powergrid.auto_discover_models_paths
, providing a simple way to register new directories to be scanned for Eloquent Models.After publishing the configuration file by running
php artisan vendor:publish --tag=livewire-powergrid-config
, users can register directories as demonstrated below:Now, when running
php artisan powergrid:create
, the user will be presented with a list of Models found in the specified directories:To maintain consistency when saving files, PowerGrid will follow the Livewire Config Key
livewire.class_namespace
.To adjust the configuration, run:
php artisan livewire:publish --config
.In our example, Livewire Namespace can be adjusted as follows:
When running
php artisan powergrid:create
, the user can enter the component name following the desired path. For example:This will result in:
As a reminder, the
Domain
directory must be added to autoload incomposer.json
:Related Issue(s): #1499
Documentation
This PR requires Documentation update?