From 5b7fcc44cf3028d0ada58f408eed2bc73900decb Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Fri, 4 Sep 2020 15:15:58 +0100 Subject: [PATCH] [DB] Add helper for removing entities --- src/Core/Entity.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Core/Entity.php b/src/Core/Entity.php index d221881427..50e39621c1 100644 --- a/src/Core/Entity.php +++ b/src/Core/Entity.php @@ -48,4 +48,13 @@ class Entity $table = Formatting::camelCaseToSnakeCase(get_called_class()); return self::create($args, DB::findBy($table, $find_by)[0]); } + + public static function remove(array $args, $obj = null) + { + $class = '\\' . get_called_class(); + if ($obj == null) { + $obj = DB::findBy($class, $args); + } + DB::remove($obj); + } }