Skip to content

Commit b4b7e67

Browse files
authored
Add proper error message if creatable attribute not defined in model (#218)
2 parents 7661897 + 149cf71 commit b4b7e67

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Phaseolies/Database/Entity/Query/InteractsWithModelQueryProcessing.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ public static function createFromModel(Model $model): static
422422
*/
423423
protected function getCreatableAttributes(): array
424424
{
425+
if (empty($this->creatable)) {
426+
throw new \RuntimeException(
427+
"Model " . static::class . " has no \$creatable attributes defined."
428+
);
429+
}
430+
425431
$creatableAttributes = [];
426432
foreach ($this->creatable as $attribute) {
427433
if (isset($this->attributes[$attribute])) {

0 commit comments

Comments
 (0)