[DB] Add helper for removing entities
This commit is contained in:
parent
ea4f2c522b
commit
5b7fcc44cf
@ -48,4 +48,13 @@ class Entity
|
|||||||
$table = Formatting::camelCaseToSnakeCase(get_called_class());
|
$table = Formatting::camelCaseToSnakeCase(get_called_class());
|
||||||
return self::create($args, DB::findBy($table, $find_by)[0]);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user