diff --git a/src/Model.php b/src/Model.php index df7cd91..fbf1c98 100644 --- a/src/Model.php +++ b/src/Model.php @@ -383,7 +383,8 @@ private function getPrefixMethod(string $method): string */ private function makeTableName(): string { - return strtolower((new NounConverter())->convertToPlural(Utils::camelToUnderscore(get_class($this)))); + $name = (new \ReflectionClass($this))->getShortName(); + return strtolower((new NounConverter())->convertToPlural(Utils::camelToUnderscore($name))); } /** @@ -675,6 +676,7 @@ public static function create(array $data, $useTransaction = false) throw new \InvalidArgumentException("Data array is empty."); } + $success = true; $v = (new DataValidator($data)); @@ -817,6 +819,7 @@ public function updateInTransaction() */ public static function get(array|string $columns = '*', ?callable $toQuery = null, ?DataRulesInterface $rules = null, ?self $model = null): ?DataCollectionInterface { + $model = $model ?? static::newInstance(); $query = Query::select($model->getTable());