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

Artisan's model:show command does not list inherited relations #48798

Closed
sebj54 opened this issue Oct 23, 2023 · 1 comment · Fixed by #48800
Closed

Artisan's model:show command does not list inherited relations #48798

sebj54 opened this issue Oct 23, 2023 · 1 comment · Fixed by #48800

Comments

@sebj54
Copy link
Contributor

sebj54 commented Oct 23, 2023

Laravel Version

10.28.0

PHP Version

8.2.11

Database Driver & Version

No response

Description

I have an abstract model in my code which is inherited by several models. The abstract model has several relations which are intended to be called from the final models.

The problem is that these inherited relations are not shown in Artisan's model:show command because of this line:

|| $method->getDeclaringClass()->getName() !== get_class($model)

If the method is not declared on the final model class, the method is skipped. I guess this is for performance reason, to avoid checking methods from the framework, for instance from Illuminate\Database\Eloquent\Model.

Couldn't we reject the method if it is declared in Illuminate\Database\Eloquent\Model? Like this, inherited relations are still shown. It could be really handy for relations declared:

  • in a trait
  • in a parent class
  • in anything from a third party package

Steps To Reproduce

  1. Create an abstract model
  2. Declare a relation inside
  3. Create a model which extends the abstract model
  4. Call php artisan model:show for this newly created model

The inherited relation is not shown

@github-actions
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants