Skip to content

Commit

Permalink
Revert "Option to use table names when morphing (laravel#38451)" (lar…
Browse files Browse the repository at this point in the history
…avel#38463)

This reverts commit 5d5655b.
  • Loading branch information
taylorotwell authored and Krisell committed Aug 20, 2021
1 parent 09d090c commit edf901d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,7 @@ public function getMorphClass()
return array_search(static::class, $morphMap, true);
}

return Relation::$useTableNamesForMorphMap
? $this->getTable()
: static::class;
return static::class;
}

/**
Expand Down
17 changes: 0 additions & 17 deletions src/Illuminate/Database/Eloquent/Relations/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ abstract class Relation
*/
protected static $constraints = true;

/**
* Indicates that table names should be used when determining morph classes.
*
* @var bool
*/
public static $useTableNamesForMorphMap = false;

/**
* An array to map class names to their morph names in the database.
*
Expand Down Expand Up @@ -383,16 +376,6 @@ protected function whereInMethod(Model $model, $key)
: 'whereIn';
}

/**
* Indicate that the table names should be used when determining morphed class names.
*
* @return void
*/
public static function morphUsingTableNames()
{
static::$useTableNamesForMorphMap = true;
}

/**
* Set or get the morph map for polymorphic relations.
*
Expand Down
10 changes: 0 additions & 10 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1217,16 +1217,6 @@ public function testMorphOneCreatesProperRelation()
$this->assertEquals(EloquentModelStub::class, $relation->getMorphClass());
}

public function testMorphOneCreatesProperRelationWhenUsingTableNames()
{
Relation::morphUsingTableNames();
$model = new EloquentModelStub;
$this->addMockConnection($model);
$relation = $model->morphOne(EloquentModelSaveStub::class, 'morph');
$this->assertEquals('stub', $relation->getMorphClass());
Relation::$useTableNamesForMorphMap = false;
}

public function testCorrectMorphClassIsReturned()
{
Relation::morphMap(['alias' => 'AnotherModel']);
Expand Down

0 comments on commit edf901d

Please sign in to comment.