Browse Source

Added new touch function to eloquent, updates timestamps and immediately saves

Signed-off-by: Callum McIntyre <mcintyre1994@gmail.com>
Callum McIntyre 12 years ago
parent
commit
6b73974505
1 changed files with 10 additions and 0 deletions
  1. 10 0
      laravel/database/eloquent/model.php

+ 10 - 0
laravel/database/eloquent/model.php

@@ -452,6 +452,16 @@ abstract class Model {
 		if ( ! $this->exists) $this->created_at = $this->updated_at;
 		if ( ! $this->exists) $this->created_at = $this->updated_at;
 	}
 	}
 
 
+	/**
+	 *Updates the timestamp on the model and immediately saves it.
+	 *
+	 * @return void
+	 */
+	public function touch(){
+		$this->timestamp();
+		$this->save();
+	}
+
 	/**
 	/**
 	 * Get a new fluent query builder instance for the model.
 	 * Get a new fluent query builder instance for the model.
 	 *
 	 *