revert eloquent back to 3.2.3

This commit is contained in:
Taylor Otwell
2012-08-17 09:18:16 -05:00
parent e8119f8109
commit 1203473469
5 changed files with 22 additions and 51 deletions

View File

@@ -44,7 +44,7 @@ class Has_Many_And_Belongs_To extends Relationship {
$this->joining = $table ?: $this->joining($model, $associated);
// If the Pivot table is timestamped, we'll set the timestamp columns to be
// fetched when the pivot table models are fetched by the developer, or else
// fetched when the pivot table models are fetched by the developer else
// the ID will be the only "extra" column fetched in by default.
if (Pivot::$timestamps)
{
@@ -61,8 +61,6 @@ class Has_Many_And_Belongs_To extends Relationship {
*
* By default, the name is the models sorted and joined with underscores.
*
* @param Model $model
* @param string $associated
* @return string
*/
protected function joining($model, $associated)
@@ -88,7 +86,7 @@ class Has_Many_And_Belongs_To extends Relationship {
* Insert a new record into the joining table of the association.
*
* @param int $id
* @param array $attributes
* @param array $joining
* @return bool
*/
public function attach($id, $attributes = array())
@@ -133,7 +131,7 @@ class Has_Many_And_Belongs_To extends Relationship {
}
// Next we will take the difference of the current and given IDs and detach
// all of the entities that exist in the current array but are not in
// all of the entities that exists in the current array but are not in
// the array of IDs given to the method, finishing the sync.
$detach = array_diff($current, $ids);
@@ -319,30 +317,22 @@ class Has_Many_And_Belongs_To extends Relationship {
/**
* Match eagerly loaded child models to their parent models.
*
* @param string $relationship
* @param array $parents
* @param array $children
* @param array $parents
* @param array $children
* @return void
*/
public function match($relationship, &$parents, $children)
{
$foreign = $this->foreign_key();
$dictionary = array();
foreach ($children as $child)
{
$dictionary[$child->pivot->$foreign][] = $child;
}
foreach ($parents as &$parent)
{
$parent_key = $parent->get_key();
if (isset($dictionary[$parent_key]))
$matching = array_filter($children, function($v) use (&$parent, $foreign)
{
$parent->relationships[$relationship] = $dictionary[$parent_key];
}
return $v->pivot->$foreign == $parent->get_key();
});
$parent->relationships[$relationship] = array_values($matching);
}
}
@@ -386,7 +376,7 @@ class Has_Many_And_Belongs_To extends Relationship {
/**
* Set the columns on the joining table that should be fetched.
*
* @param array $columns
* @param array $column
* @return Relationship
*/
public function with($columns)