Commit 7518088f by Taylor Otwell

use service location in eloquent models to resolve the database manager.

parent 6281c8c3
......@@ -2,7 +2,6 @@
use Laravel\Str;
use Laravel\Inflector;
use Laravel\Database\Manager;
abstract class Model {
......@@ -133,7 +132,7 @@ abstract class Model {
// Since this method is only used for instantiating models for querying
// purposes, we will go ahead and set the Query instance on the model.
$model->query = Manager::connection(static::$connection)->table(static::table($class));
$model->query = IoC::resolve('laravel.database')->connection(static::$connection)->table(static::table($class));
return $model;
}
......@@ -347,7 +346,7 @@ abstract class Model {
// Since the model was instantiated using "new", a query instance has not been set.
// Only models being used for querying have their query instances set by default.
$this->query = Manager::connection(static::$connection)->table(static::table($model));
$this->query = IoC::resolve('laravel.database')->connection(static::$connection)->table(static::table($model));
if (property_exists($model, 'timestamps') and $model::$timestamps)
{
......@@ -396,7 +395,7 @@ abstract class Model {
// delete statement to the query instance.
if ( ! $this->exists) return $this->query->delete();
return Manager::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
return IoC::resolve('laravel.database')->connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
}
/**
......
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