vanilophp/demo

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

Opened this issue · 0 comments

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