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

[9.x] Change how Laravel handles strict morph map with pivot classes #41304

Merged

Conversation

crynobone
Copy link
Member

  • Generic Pivot class should always be ignored as it doesn't have any knowledge of the exact usage and is generated automatically by Laravel.
  • Custom Pivot class should work the same as a normal model class since it is defined manually by the developer.

In Laravel Nova, when we attach, update attached, and detach resources we
would store the pivot model in action_events table and this can cause
issue when the developer attempt to use Relation::requireMorphMap().

Signed-off-by: Mior Muhammad Zaki crynobone@gmail.com

* Generic Pivot class should always be ignored as it doesn't have any
  knowledge of the exact usage and generated automatically by Laravel.
* Custom Pivot class should work the same as normal class since it
  defined manually by developer.

In Laravel Nova, when we attach, update attached and detach resources we
would store the pivot model in `action_events` table and this can cause
issue when developer attempt to enable strict morph map.

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
@@ -39,7 +40,7 @@ public function testStrictModeDoesNotThrowExceptionWhenMorphMap()

public function testMapsCanBeEnforcedInOneMethod()
{
$model = TestModel::make();
$model = new TestModel;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faced issue while running test on single file:

image

Change to new TestModel fixed that.

@taylorotwell taylorotwell merged commit 1678dc7 into laravel:9.x Mar 3, 2022
@crynobone crynobone deleted the patch-pivot-class-enforced-morph-map branch March 3, 2022 22:14
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.

None yet

2 participants