Commit 4243e721 authored by Taylor Otwell's avatar Taylor Otwell

Return a boolean success or failure when saving Eloquent models.

parent 87a65c20
...@@ -353,7 +353,7 @@ abstract class Model { ...@@ -353,7 +353,7 @@ abstract class Model {
/** /**
* Save the model to the database. * Save the model to the database.
* *
* @return void * @return bool
*/ */
public function save() public function save()
{ {
...@@ -376,16 +376,16 @@ abstract class Model { ...@@ -376,16 +376,16 @@ abstract class Model {
// Otherwise, we will insert the model and set the ID attribute. // Otherwise, we will insert the model and set the ID attribute.
if ($this->exists) if ($this->exists)
{ {
$this->query->where_id($this->attributes['id'])->update($this->dirty); $success = ($this->query->where_id($this->attributes['id'])->update($this->dirty) === 1);
} }
else else
{ {
$this->attributes['id'] = $this->query->insert_get_id($this->attributes); $success = is_numeric($this->attributes['id'] = $this->query->insert_get_id($this->attributes));
} }
$this->exists = true; ($this->exists = true) and $this->dirty = array();
$this->dirty = array(); return $success;
} }
/** /**
......
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