Skip to content

ClassMorphViolationException exception with model:show artisan command #43216

Closed
@SamuelMwangiW

Description

@SamuelMwangiW
  • Laravel Version: 9.x-dev
  • PHP Version: 8.1.7
  • Database Driver & Version: Mariadb 10.7

Description:

Thanks a lot for the amazing work @jessarcher on #43156 .

Am getting an Illuminate\Database\ClassMorphViolationException because I have Relation::enforceMorphMap for some classes. Kindly confirm if this is the desired behavior
image

Relation::enforceMorphMap([
    'post' => Post::class,
    'video' => Video::class,
]);

It otherwise works perfectly fine when the enforceMorphMap is commented out:
image

Steps To Reproduce:

  • Add Relation::enforceMorphMap(['model'=>'App\Models\Model']) in the boot method of AppServiceProvider and omitting to add \App\Models\User
  • Run artisan model:show User

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