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
Now lets say i have a $cart and i want to get the lines
$cart->load('lines');
I will get back an object with Lunar\Models\Cartline while i also have a App\Domain\Models\CartLine also extending its counterpart.
After extensive debugging i have figured out the following. The addDirectory is what is causing the the method call to extending(BaseModel::class) is returning false for all the objects. If i comment this out it works as expected and returns me the App\Domain\Models\CartLine as expected.
<?phpnamespaceLunar\Base;
classModelManifestimplementsModelManifestInterface
{
/** * Add a directory of models. */publicfunctionaddDirectory(string$dir): void
{
try {
$modelClasses = Discover::in($dir)
->classes()
// ->extending(BaseModel::class) If you remove this line it works as expected
->get();
foreach ($modelClassesas$modelClass) {
$interfaceClass = $this->guessContractClass($modelClass);
$this->models[$interfaceClass] = $modelClass;
$this->bindModel($interfaceClass, $modelClass);
}
} catch (DirectoryNotFoundException$e) {
Log::error($e->getMessage());
}
}
}
Expected Behaviour:
When i have a custom model e.g. App\Domain\Models\Cart i extend the original Lunar cart object.
Now lets say i have a $cart and i want to get the lines
I will get back an object with Lunar\Models\Cartline while i also have a App\Domain\Models\CartLine also extending its counterpart.
After extensive debugging i have figured out the following. The addDirectory is what is causing the the method call to extending(BaseModel::class) is returning false for all the objects. If i comment this out it works as expected and returns me the App\Domain\Models\CartLine as expected.
I'm not 100% sure if this is intended behaviour because according to the docs there is a way to retrieve your model back: https://docs.lunarphp.io/core/extending/models.html#relationship-support
The text was updated successfully, but these errors were encountered: