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

Order of registering modules appears to remove customers relationship from Address class. #117

Open
j-dohnalek opened this issue Dec 5, 2023 · 0 comments

Comments

@j-dohnalek
Copy link

j-dohnalek commented Dec 5, 2023

Not sure if this is the correct place to raise the question. I hope the below explanation makes sense.

After installing the demo repository and setting everything up, we noticed that step 1 and step 2 happen during boot of application.

The issue is that after the second module registration Address::class looses the relationship customers(): BelongsToMany.

Is this correct?

Step 1

https://github.com/artkonekt/appshell/blob/61ea8b7c8e715884ab6598acccfdff6796dcc1b0/src/Providers/ModuleServiceProvider.php#L114

First loads the following module
Konekt\AppShell\Providers\ModuleServiceProvider::boot and it runs the following lines

use Konekt\Address\Contracts\Address as AddressContract;
use Konekt\AppShell\Models\Address;

$this->concord->registerModel(AddressContract::class, Address::class);

The Konekt\AppShell\Models\Address::class now has extends Konekt\Address\Models\Address and has relationships as below:

public function country(): BelongsTo
public function province(): BelongsTo
public function customers(): BelongsToMany

Step 2

https://github.com/vanilophp/framework/blob/57298341e8e11659ec2b8a28e381fe82862cdc1e/src/Foundation/Providers/ModuleServiceProvider.php#L85C8-L85C101

Sometimes after the following module load Vanilo\Foundation\Providers\ModuleServiceProvider::boot

use Konekt\Address\Contracts\Address as AddressContract;
use Vanilo\Foundation\Models\Address;

$this->concord->registerModel(AddressContract::class, Address::class, $registerRouteModels);

The Vanilo\Foundation\Models\Address::class now extends Konekt\Address\Models\Address::class and has relationships as below:

public function country(): BelongsTo
public function province(): BelongsTo
@j-dohnalek j-dohnalek changed the title Order of registering modules appers to remove customer relationship from Address class. Order of registering modules appears to remove customer relationship from Address class. Dec 5, 2023
@j-dohnalek j-dohnalek changed the title Order of registering modules appears to remove customer relationship from Address class. Order of registering modules appears to remove customers relationship from Address class. Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant