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

Fix #1300 relation_return_type must take precedence if it is defined #1394

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

menthol
Copy link
Contributor

@menthol menthol commented Nov 18, 2022

Summary

The rrelation_return_type must take priority if it is defined so that the choice that the user imposes in the options is used without the automatic detection overloading it.

Currently, it is not possible to define a one relationship if somewhere in the name of the relationship object there is the word Many.

ex:

# Model
public function propertyManagementCompany(): Staudenmeir\EloquentHasManyDeep\HasOneDeep
    {
        return $this->hasOneDeep(PropertyManagementCompany::class, ['landlord_user', User::class, 'property_management_company_user']);
    }

# config/ide-helper.php
    'additional_relation_types' => [
        'hasOneDeep' => \Staudenmeir\EloquentHasManyDeep\HasOneDeep::class,
    ],
    'additional_relation_return_types' => [
        'hasOneDeep' => 'one', # No many, no morphTo, no falsy
    ],

# currently generate
/**
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\PropertyManagementCompany[] $propertyManagementCompany
 * @property-read int|null $property_management_company_count
 */

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Misc. change (internal, infrastructure, maintenance, etc.)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Add a CHANGELOG.md entry
  • Update the README.md
  • Code style has been fixed via composer fix-style

@menthol menthol marked this pull request as draft November 18, 2022 20:48
@menthol menthol marked this pull request as ready for review November 21, 2022 14:38
@barryvdh
Copy link
Owner

barryvdh commented Feb 8, 2024

Closing to trigger tests

@barryvdh barryvdh closed this Feb 8, 2024
@barryvdh barryvdh reopened this Feb 8, 2024
@barryvdh barryvdh merged commit cee441c into barryvdh:master Feb 8, 2024
33 checks passed
@barryvdh
Copy link
Owner

barryvdh commented Feb 8, 2024

Thanks

d3v2a pushed a commit to d3v2a/laravel-ide-helper that referenced this pull request Feb 16, 2024
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

Successfully merging this pull request may close these issues.

2 participants