1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

make empty prefs object instead of array

This commit is contained in:
Damodar Lohani 2021-12-30 11:55:17 +05:45
parent 166ebf7225
commit 297d03126e

View file

@ -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
*