Commit 2ac5a372 authored by Taylor Otwell's avatar Taylor Otwell

cleaning up eloquent models.

parent b93a1220
......@@ -147,7 +147,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 = IoC::core('database')->connection(static::$connection)->table(static::table($class));
$model->query = IoC::container()->core('database')->connection(static::$connection)->table(static::table($class));
return $model;
}
......@@ -361,7 +361,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 = IoC::core('database')->connection(static::$connection)->table(static::table($model));
$this->query = IoC::container()->core('database')->connection(static::$connection)->table(static::table($model));
if (property_exists($model, 'timestamps') and $model::$timestamps)
{
......@@ -410,7 +410,9 @@ abstract class Model {
// delete statement to the query instance.
if ( ! $this->exists) return $this->query->delete();
return IoC::core('database')->connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
$table = static::table(get_class($this));
return IoC::container()->core('database')->connection(static::$connection)->table($table)->delete($this->id);
}
/**
......@@ -487,7 +489,7 @@ abstract class Model {
// All of the aggregate and persistance functions can be passed directly to the query
// instance. For these functions, we can simply return the response of the query.
if (in_array($method, array('insert', 'update', 'count', 'sum', 'min', 'max', 'avg')))
if (in_array($method, array('insert', 'update', 'abs', 'count', 'sum', 'min', 'max', 'avg')))
{
return call_user_func_array(array($this->query, $method), $parameters);
}
......
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