Commit 5493b6b1 authored by Jens Segers's avatar Jens Segers

Now using v4.0.x packages

parent 3827a515
......@@ -81,7 +81,7 @@ Everything else works just like the original Eloquent model. Read more about the
Query Builder
-------------
Once selected a mongodb connection, you can execute queries just like the original query builder. The main difference is that we are using `collection` instead of `table` (but table will work as well), and some additional operations like `push` and `pull`.
Once you have selected a mongodb connection, you can execute queries just like the original query builder. The main difference is that we are using `collection` instead of `table` (but table will work as well), and some additional operations like `push` and `pull`.
// With custom connection
$user = DB::connection('mongodb')->collection('users')->get();
......
......@@ -11,12 +11,12 @@
"license" : "MIT",
"require": {
"php": ">=5.3.0",
"illuminate/support": "~4.0",
"illuminate/database": "~4.0",
"illuminate/events": "~4.0"
"illuminate/support": "4.0.x",
"illuminate/database": "4.0.x",
"illuminate/events": "4.0.x"
},
"require-dev": {
"illuminate/cache": "~4.0"
"illuminate/cache": "4.0.x"
},
"autoload": {
"psr-0": {
......
......@@ -11,7 +11,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
*
* @var MongoCollection
*/
public $collection;
protected $collection;
/**
* All of the available operators.
......@@ -495,7 +495,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
*
* @return array
*/
private function compileWheres()
protected function compileWheres()
{
if (!$this->wheres) return array();
......@@ -507,6 +507,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
// Convert id's
if (isset($where['column']) && $where['column'] == '_id')
{
// Multiple values
if (isset($where['values']))
{
foreach ($where['values'] as &$value)
......@@ -514,6 +515,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
$value = ($value instanceof MongoID) ? $value : new MongoID($value);
}
}
// Single value
else
{
$where['value'] = ($where['value'] instanceof MongoID) ? $where['value'] : new MongoID($where['value']);
......@@ -544,7 +546,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $wheres;
}
private function compileWhereBasic($where)
protected function compileWhereBasic($where)
{
extract($where);
......@@ -573,28 +575,28 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $query;
}
private function compileWhereNested($where)
protected function compileWhereNested($where)
{
extract($where);
return $query->compileWheres();
}
private function compileWhereIn($where)
protected function compileWhereIn($where)
{
extract($where);
return array($column => array('$in' => $values));
}
private function compileWhereNotIn($where)
protected function compileWhereNotIn($where)
{
extract($where);
return array($column => array('$nin' => $values));
}
private function compileWhereNull($where)
protected function compileWhereNull($where)
{
$where['operator'] = '=';
$where['value'] = null;
......@@ -602,7 +604,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $this->compileWhereBasic($where);
}
private function compileWhereNotNull($where)
protected function compileWhereNotNull($where)
{
$where['operator'] = '!=';
$where['value'] = null;
......@@ -610,7 +612,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $this->compileWhereBasic($where);
}
private function compileWhereBetween($where)
protected function compileWhereBetween($where)
{
extract($where);
......@@ -621,7 +623,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
);
}
private function compileWhereRaw($where)
protected function compileWhereRaw($where)
{
return $where['sql'];
}
......
......@@ -9,12 +9,15 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo {
*/
public function addConstraints()
{
// For belongs to relationships, which are essentially the inverse of has one
// or has many relationships, we need to actually query on the primary key
// of the related models matching on the foreign key that's on a parent.
$key = $this->related->getKeyName();
if (static::$constraints)
{
// For belongs to relationships, which are essentially the inverse of has one
// or has many relationships, we need to actually query on the primary key
// of the related models matching on the foreign key that's on a parent.
$key = $this->related->getKeyName();
$this->query->where($key, '=', $this->parent->{$this->foreignKey});
$this->query->where($key, '=', $this->parent->{$this->foreignKey});
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment