Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
crynobone:patch-pivot-class-enforced-morph-map
Mar 3, 2022
Merged

[9.x] Change how Laravel handles strict morph map with pivot classes#41304
taylorotwell merged 1 commit into
laravel:9.xfrom
crynobone:patch-pivot-class-enforced-morph-map

Conversation

@crynobone
Copy link
Copy Markdown
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>
public function testMapsCanBeEnforcedInOneMethod()
{
$model = TestModel::make();
$model = new TestModel;
Copy link
Copy Markdown
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.

2 participants