Commit 75f63847 by Taylor Otwell

fix eloquent->delete bug.

parent b870ac09
...@@ -379,6 +379,19 @@ abstract class Model { ...@@ -379,6 +379,19 @@ abstract class Model {
} }
/** /**
* Delete the model from the database.
*
* @return int
*/
public function delete()
{
if ($this->exists)
{
return $this->query()->where(static::$key, '=', $this->get_key())->delete();
}
}
/**
* Set the update and creation timestamps on the model. * Set the update and creation timestamps on the model.
* *
* @return void * @return void
......
...@@ -125,9 +125,7 @@ class Has_Many_And_Belongs_To extends Relationship { ...@@ -125,9 +125,7 @@ class Has_Many_And_Belongs_To extends Relationship {
*/ */
public function delete() public function delete()
{ {
$id = $this->base->get_key(); return $this->pivot()->delete();
return $this->joining_table()->where($this->foreign_key(), '=', $id)->delete();
} }
/** /**
......
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