[DB] Add helper for removing entities

This commit is contained in:
Hugo Sales 2020-09-04 15:15:58 +01:00 committed by Hugo Sales
parent ea4f2c522b
commit 5b7fcc44cf
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -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);
}
}