Fixing bugs in Eq2.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell
2012-03-16 10:29:43 -05:00
parent e857505e35
commit c9c0ddf569
5 changed files with 36 additions and 9 deletions

View File

@@ -133,7 +133,7 @@ class Has_Many_And_Belongs_To extends Relationship {
*/
protected function set_select($foreign)
{
$foreign = $this->joining.'.'.$foreign.' as eloquent_foreign_key';
$foreign = $this->joining.'.'.$foreign.' as pivot_foreign_key';
$this->table->select(array($this->model->table().'.*', $foreign));
@@ -201,7 +201,7 @@ class Has_Many_And_Belongs_To extends Relationship {
*/
public function match($relationship, &$parents, $children)
{
$foreign = 'eloquent_foreign_key';
$foreign = 'pivot_foreign_key';
foreach ($children as $key => $child)
{
@@ -216,6 +216,20 @@ class Has_Many_And_Belongs_To extends Relationship {
}
}
/**
* Clean-up any pivot columns that are on the results.
*
* @param array $results
* @return void
*/
protected function clean(&$results)
{
foreach ($results as &$result)
{
}
}
/**
* Get the other or associated key for the relationship.
*

View File

@@ -1,4 +1,6 @@
<?php namespace Laravel\Database\Eloquent\Relationships; use Eloquent\Model;
<?php namespace Laravel\Database\Eloquent\Relationships;
use Laravel\Database\Eloquent\Model;
class Has_One_Or_Many extends Relationship {

View File

@@ -1,4 +1,7 @@
<?php namespace Laravel\Database\Eloquent\Relationships; use Eloquent\Model, Eloquent\Query;
<?php namespace Laravel\Database\Eloquent\Relationships;
use Laravel\Database\Eloquent\Model;
use Laravel\Database\Eloquent\Query;
abstract class Relationship extends Query {