@@ -17,13 +17,18 @@ abstract class Base {
1717 /**
1818 * @var string Primary key of current model
1919 */
20- protected static $ primary_key ;
20+ protected static $ primary_key = ' id ' ;
2121
2222 /**
2323 * @var string It will contain an array of all fields that are present in database in table
2424 */
2525 protected $ fields ;
2626
27+ /**
28+ * @var bool Weather the model needs timestamp whenever it's updated
29+ */
30+ protected static $ needs_update_timestamp = false ;
31+
2732 /**
2833 * Base constructor.
2934 *
@@ -161,13 +166,13 @@ public static function create( $columns = [] ) {
161166 * Returns all model with condition
162167 *
163168 * @param string|array $column Column to search in
164- * @param string|int $value Value to match
169+ * @param string $value Value to match
165170 *
166171 * @throws \Exception
167172 *
168173 * @return array
169174 */
170- public static function where ( $ column , $ value ) {
175+ public static function where ( $ column , $ value= '' ) {
171176 return static ::many_array_to_model (
172177 EE ::db ()
173178 ->table ( static ::$ table )
@@ -240,11 +245,15 @@ public function __unset( $name ) {
240245 * @return bool Model saved successfully
241246 */
242247 public function save () {
243- $ fields = array_merge (
244- $ this ->fields , [
245- 'modified_on ' => date ( 'Y-m-d H:i:s ' ),
246- ]
247- );
248+ $ fields = $ this ->fields ;
249+
250+ if ( static ::$ needs_update_timestamp ) {
251+ $ fields = array_merge (
252+ $ fields , [
253+ 'modified_on ' => date ( 'Y-m-d H:i:s ' ),
254+ ]
255+ );
256+ }
248257
249258 $ primary_key_column = static ::$ primary_key ;
250259
0 commit comments