Skip to content

Commit 15196dd

Browse files
author
Carlos Garcia
committed
Solucionados los problemas al recuperar modelos de la caché.
1 parent eeb437f commit 15196dd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Core/Template/ModelClass.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,13 @@ public function test(): bool
540540
return false;
541541
}
542542

543-
// comprobamos que los campos no nulos tengan algún valor asignado
543+
// comprobamos que los campos estén definidos
544544
$fields = $this->getModelFields();
545545
if (empty($fields)) {
546-
return false;
546+
throw new Exception('The model fields are not defined in the model ' . $this->modelClassName());
547547
}
548+
549+
// comprobamos que los campos no nulos tengan algún valor asignado
548550
$return = true;
549551
foreach ($fields as $key => $value) {
550552
if ($key == static::primaryColumn()) {

Core/Template/ModelTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public static function findOrCreate(array $where, array $data = []): ?static
136136
*/
137137
public function getModelFields(): array
138138
{
139+
if (empty($this->fields)) {
140+
$this->loadModelFields();
141+
}
142+
139143
return static::$fields;
140144
}
141145

0 commit comments

Comments
 (0)