我需要重写函数function runSample()
{
// Put the folder ID including files you want to convert.
const folderId = "### folderId ###";
// Retrieve file list.
drive.files.list(
{
pageSize: 1000,
q: `'${folderId}' in parents and (mimeType='image/png' or mimeType='image/jpeg' or mimeType='image/tiff')`,
fields: 'files(id)',
}, (err, res) =>
{
if (err)
{
console.error(err);
return;
}
const files = res.data.files;
// Retrieve each file from the retrieved file list.
files.forEach((file) =>
{
const params = {
fileId: file.id,
resource:
{
mimeType: 'application/vnd.google-apps.document',
parents: ['### folderId ###'],
},
fields: 'id',
};
// Convert a file
drive.files.copy(params, (err, res) =>
{
if (err)
{
console.error(err);
return;
}
console.log(res.data.id);
});
});
});
}
来检查用户是否具有获取特定列的适当权限,因此我创建了此函数:
toArray()
但是当我在控制器中使用public function toArray( $options = 0 )
{
if(!auth()->user()->hasPermissionTo('users.show.email')) {
$this->hidden[] = 'email';
}
// etc ...
return parent::toJson($options);
}
来列出所有用户时,我没有任何结果,但是60秒后我得到了:
User::Get()
如果我不重写[2019-04-06 23:18:33] local.ERROR: Maximum execution time of 60 seconds exceeded {"userId":1,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Maximum execution time of 60 seconds exceeded at C:\\xampp\\htdocs\\starter\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Arr.php:162)
[stacktrace]
函数,一切都很好。
答案 0 :(得分:5)
在最后一行,您要调用rm **/!(*.py)
方法,该方法在内部calls $this->jsonSerialize()
,而这个方法calls $this->toArray()
—您的重写函数,因此将进入无限调用循环。
在覆盖的函数中,您应该改为调用parent::toJson()
。