Skip to content

Support for enforceMorphMap in InteractionRelation Queries #112

@Sparkamplover

Description

@Sparkamplover

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions