make empty prefs object instead of array
This commit is contained in:
parent
166ebf7225
commit
297d03126e
|
@ -4,6 +4,8 @@ namespace Appwrite\Utopia\Response\Model;
|
|||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use stdClass;
|
||||
use Utopia\Database\Document;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
|
@ -61,6 +63,24 @@ class User extends Model
|
|||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function filter(Document $document): Document
|
||||
{
|
||||
$prefs = $document->getAttribute('prefs');
|
||||
if($prefs instanceof Document) {
|
||||
$prefs = $prefs->getArrayCopy();
|
||||
}
|
||||
|
||||
if(is_array($prefs) && empty($prefs)) {
|
||||
$document->setAttribute('prefs', new stdClass);
|
||||
}
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue