You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using custom models to overwrite the framework models via ModelManifest::addDirectory(dir: app_path('Domain/Models'));, all internal references to models within the framework (e.g., Lunar\Actions\*) should respect and use the custom models instead of the hardcoded framework models. This allows seamless integration of custom logic without requiring additional overwrites in action classes.
Actual Behaviour:
Inside the vendor/lunarphp/core/src/Actions/* directory, several actions are hardcoding references to the framework's models instead of leveraging the custom models. For example, in Lunar\Actions\Carts\CreateOrder, the Order model is hardcoded with new Order, bypassing the custom model provided in ModelManifest. This makes it necessary to overwrite the entire class or configure it in config/lunar/cart.php, even when the custom logic differs minimally from the original implementation.
Steps To Reproduce:
Add custom models to overwrite Lunar's default models using ModelManifest::addDirectory(dir: app_path('Domain/Models'));.
Attempt to use the framework actions, such as Lunar\Actions\Carts\CreateOrder, that rely on the hardcoded models (e.g., new Order).
Observe that the custom model logic is not applied due to the package's hardcoded references.
Attempt to customize the functionality without overwriting or explicitly configuring the action in config/lunar/cart.php.
Modify the package's action classes to dynamically resolve models via the ModelManifest or similar mechanisms instead of hardcoding models directly. For example, replace new Order with resolve(ModelManifest::class)->get(Order::class) or a similar approach. This would ensure the custom models are used wherever applicable.
Expected Behaviour:
When using custom models to overwrite the framework models via
ModelManifest::addDirectory(dir: app_path('Domain/Models'));
, all internal references to models within the framework (e.g.,Lunar\Actions\*
) should respect and use the custom models instead of the hardcoded framework models. This allows seamless integration of custom logic without requiring additional overwrites in action classes.Actual Behaviour:
Inside the
vendor/lunarphp/core/src/Actions/*
directory, several actions are hardcoding references to the framework's models instead of leveraging the custom models. For example, inLunar\Actions\Carts\CreateOrder
, theOrder
model is hardcoded withnew Order
, bypassing the custom model provided inModelManifest
. This makes it necessary to overwrite the entire class or configure it inconfig/lunar/cart.php
, even when the custom logic differs minimally from the original implementation.Steps To Reproduce:
ModelManifest::addDirectory(dir: app_path('Domain/Models'));
.Lunar\Actions\Carts\CreateOrder
, that rely on the hardcoded models (e.g.,new Order
).config/lunar/cart.php
.Code Example:
Here's an example of the issue:
Suggested Solution:
Modify the package's action classes to dynamically resolve models via the ModelManifest or similar mechanisms instead of hardcoding models directly. For example, replace new Order with resolve(ModelManifest::class)->get(Order::class) or a similar approach. This would ensure the custom models are used wherever applicable.
This would maintain compatibility with custom logic while preserving the default package behavior.
The text was updated successfully, but these errors were encountered: