Skip to content

Commit

Permalink
Revert table name as morph type (#35533)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Dec 8, 2020
1 parent 83a2fd8 commit 2446a91
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
Expand Up @@ -731,10 +731,6 @@ public function getMorphClass()
return array_search(static::class, $morphMap, true);
}

if (Relation::$tableNameAsMorphType) {
return $this->getTable();
}

return static::class;
}

Expand Down
17 changes: 0 additions & 17 deletions src/Illuminate/Database/Eloquent/Relations/Relation.php
Expand Up @@ -55,13 +55,6 @@ abstract class Relation
*/
public static $morphMap = [];

/**
* Indicates if the morph relation type should default to table name.
*
* @var bool
*/
public static $tableNameAsMorphType = false;

/**
* The count of self joins.
*
Expand Down Expand Up @@ -366,16 +359,6 @@ public static function morphMap(array $map = null, $merge = true)
return static::$morphMap;
}

/**
* Specifies that the morph types should be table names.
*
* @return void
*/
public static function tableNameAsMorphType()
{
self::$tableNameAsMorphType = true;
}

/**
* Builds a table-keyed array from model class names.
*
Expand Down
17 changes: 0 additions & 17 deletions tests/Database/DatabaseEloquentModelTest.php
Expand Up @@ -1211,23 +1211,6 @@ public function testCorrectMorphClassIsReturned()
}
}

public function testCorrectMorphClassIsReturnedOnChangingDefault()
{
Relation::tableNameAsMorphType();
Relation::morphMap(['alias' => EloquentModelCamelStub::class]);
Relation::morphMap(['alias2' => 'AnotherModel']);
$model = new EloquentModelStub;
$model2 = new EloquentModelCamelStub;

try {
$this->assertEquals('stub', $model->getMorphClass());
$this->assertEquals('alias', $model2->getMorphClass());
} finally {
Relation::morphMap([], false);
Relation::$tableNameAsMorphType = false;
}
}

public function testHasManyCreatesProperRelation()
{
$model = new EloquentModelStub;
Expand Down

0 comments on commit 2446a91

Please sign in to comment.