Refactoring Eloquent.
This commit is contained in:
parent
db391b8090
commit
2aef4de8d5
|
@ -146,10 +146,7 @@ public static function query($class)
|
||||||
*/
|
*/
|
||||||
public static function table($class)
|
public static function table($class)
|
||||||
{
|
{
|
||||||
if (property_exists($class, 'table'))
|
if (property_exists($class, 'table')) return $class::$table;
|
||||||
{
|
|
||||||
return $class::$table;
|
|
||||||
}
|
|
||||||
|
|
||||||
return strtolower(Inflector::plural(static::model($class)));
|
return strtolower(Inflector::plural(static::model($class)));
|
||||||
}
|
}
|
||||||
|
@ -400,10 +397,7 @@ private function timestamp()
|
||||||
{
|
{
|
||||||
$this->updated_at = date('Y-m-d H:i:s');
|
$this->updated_at = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
if ( ! $this->exists)
|
if ( ! $this->exists) $this->created_at = $this->updated_at;
|
||||||
{
|
|
||||||
$this->created_at = $this->updated_at;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -418,12 +412,9 @@ public function delete($id = null)
|
||||||
// that model. If it is being called from an Eloquent query model, it is probably
|
// that model. If it is being called from an Eloquent query model, it is probably
|
||||||
// the developer's intention to delete more than one model, so we will pass the
|
// the developer's intention to delete more than one model, so we will pass the
|
||||||
// delete statement to the query instance.
|
// delete statement to the query instance.
|
||||||
if ($this->exists)
|
if ( ! $this->exists) return $this->query->delete();
|
||||||
{
|
|
||||||
return Manager::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->query->delete();
|
return Manager::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue