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

Support for enforceMorphMap in InteractionRelation Queries #112

Open
Sparkamplover opened this issue Dec 21, 2024 · 0 comments
Open

Support for enforceMorphMap in InteractionRelation Queries #112

Sparkamplover opened this issue Dec 21, 2024 · 0 comments

Comments

@Sparkamplover
Copy link

Description:
I am experiencing an issue when using the enforceMorphMap method in my Laravel application. The package does not seem to respect the morph map defined in App\Providers\AppServiceProvider, which leads to incorrect queries being generated.

Steps to Reproduce:

  1. Define a morph map in AppServiceProvider using Relation::enforceMorphMap:
use Illuminate\Database\Eloquent\Relations\Relation;

public function boot()
{
    Relation::enforceMorphMap([
        'amp' => 'App\Models\Amp',
        // Other mappings
    ]);
}
  1. Attempt to retrieve popular interactions using:
    $relations = InteractionRelation::popular('amp')->get();

  2. The query generated looks for subject_type = 'App\Models\Amp' in the interactions table, instead of using the morph map key 'amp'.

Expected Behavior:
The package should respect the morph map and generate queries using the morph map key defined in enforceMorphMap, such as subject_type = 'amp'.

Actual Behavior:
The package generates queries using the fully qualified class name, ignoring the morph map, which results in incorrect query conditions.

Additional Context:
Laravel Version: 11.36.1
Package Version: 3.6.1
PHP Version: 8.3.15

Thank you for your attention to this matter. Please let me know if you need any more information or if there's anything I can do to assist in resolving this issue.

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