diff --git a/src/Abstracts/DataModel.php b/src/Abstracts/DataModel.php index b409706..6eca948 100644 --- a/src/Abstracts/DataModel.php +++ b/src/Abstracts/DataModel.php @@ -227,4 +227,4 @@ protected function _delete_where( $args ) global $wpdb; return $wpdb->delete( $this->tablename, $args ); } -} \ No newline at end of file +} diff --git a/src/Traits/DataModelTrait.php b/src/Traits/DataModelTrait.php index c11296b..2d85ab2 100644 --- a/src/Traits/DataModelTrait.php +++ b/src/Traits/DataModelTrait.php @@ -172,4 +172,29 @@ public static function update_all( $set, $where = [] ) ->where( $where ) ->update(); } -} \ No newline at end of file + + + /** + * Modify by ID + * @param int $id + * @param array $data + * @return bool + */ + public static function modify($id, $data) + { + $model = new self([], $id); + $model->load(); + return $model->update($data); + } + /** + * Destroy Model statically + * @param int $id + * @return \TenQuality\WP\Database\Abstracts\DataModel + */ + public static function destroy($id) + { + $model = new self([], $id); + $model->load(); + return $model->delete(); + } +}