Skip to content

Commit 638f3bf

Browse files
author
David Nahodyl
committed
fixed container identification error
1 parent f140f55 commit 638f3bf

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/Database/Eloquent/FMModel.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,26 @@ public function getContainersToWrite(){
428428
return $containers;
429429
}
430430

431-
protected function isContainer($field){
432-
return
433-
is_a($field, File::class) ||
434-
is_a($field, UploadedFile::class) ||
435-
(
436-
is_array($field) &&
437-
sizeof($field) === 2
438-
);
431+
protected function isContainer($field)
432+
{
433+
434+
// if this is a file then we know it's a container
435+
if ($this->isFile($field)) {
436+
return true;
437+
}
438+
439+
// if it's an array, it could be a file => filename key-value pair.
440+
// it's a conainer if the first object in the array is a file
441+
if (is_array($field) && sizeof($field) === 2 && $this->isFile($field[0]) ){
442+
return true;
443+
}
444+
445+
return false;
446+
}
447+
448+
protected function isFile($object){
449+
return (is_a($object, File::class) ||
450+
is_a($object, UploadedFile::class));
439451
}
440452

441453
/**

0 commit comments

Comments
 (0)