- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我需要覆盖函数 toArray()
来检查用户是否有适当的权限来获取特定的列,所以我创建了这个函数:
public function toArray( $options = 0 )
{
if(!auth()->user()->hasPermissionTo('users.show.email')) {
$this->hidden[] = 'email';
}
// etc ...
return parent::toJson($options);
}
但是当我在 Controller 中使用 User::Get()
来获取所有用户的列表时,我没有得到任何结果,但是 60 秒后我得到:
[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]
如果我不覆盖 toArray()
函数,一切都很好。
最佳答案
在最后一行,您调用了 parent::toJson()
方法,它在内部 calls $this->jsonSerialize()
,还有这个 calls $this->toArray()
— 您的重写函数,因此进入无限调用循环。
在您重写的函数中,您应该改为调用 parent::toArray()
。
关于php - "Maximum execution time of 60 seconds is exceeded"当我重写 toArray() 函数时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55554373/
我一直在学习如何使用 java 进行编程,但对于 LinkedList 的 toArray(T[] a) 的区别我还没有得到任何明确的解释和 toArray() 方法。第二个简单地将 LinkedLi
查看 java 集合框架的 java api,我在 HashSet 中找不到 toArray() 方法,抽象类 Set 中有 toArray() 方法。 class Ideone { publ
对不起,如果我问的是愚蠢的问题,但任何人都可以解释以下两个调用 (ToArray) 之间的区别。在智能感知中,它不会将它们显示为重载方法,当然这两个调用的输出是相同的。 List i = new Li
考虑以下代码: List myList = Arrays.asList(1, 2, 3); String[] myArray1 = myList.toArray(new String[myList.s
我有一个ArrayList叫listtable 。由于某种原因Clause[] whatever = listtable.toArray()给出不兼容的类型错误,但 Clause[] whatever
我从不使用重载版本的 toArray Object[] toArray(Object[] a) 将集合转换为数组。 下面是我的javacode- public class Track { publi
我需要将 ID 列表转换为 ID 数组。我可以通过多种方式做到这一点,但不确定应该使用哪一种。 说, 1. ids.stream().toArray(Id[]::new) 2. ids.toArray
我试图通过在类中实现 List 接口(interface)来稍微调整 List。 我可以毫无问题地重写和实现所有方法,除了这个: T[] toArray(T[] a); Android Studio
我对 Node.js 和 MongoDB 非常陌生,正在尝试拼凑我自己的博客应用程序。我在尝试通过我的“博客”模型查询具有特定用户名的模型时遇到问题。当我尝试运行时: var userBlogs =
根据 toArray() 的 java 文档返回包含此集合中所有元素的数组。 和 toArray(Object obj[])。返回包含此集合中所有元素的数组;返回数组的运行时类型是指定数组的类型。 第
当尝试从 IEnumerable 对象集合中获取对象数组时(与我想要的数组不同的转换方式),我知道我可以先将源集合转换为正确的类型,然后从中获取数组,但是方法 ToArray() 给我的印象是它可以一
这些查询之间有区别吗?我很想知道 mongo 如何解释传递给 map 方法的 javascript 代码与查询解析后的映射。 db.collection('myCollection').find()
假设我有一个 ArrayList ArrayList myList; 我想调用toArray,是否有性能原因需要使用 MyClass[] arr = myList.toArray(new MyClas
我有一个 List在 Java 中,并希望将其转换为数组。 起初,我使用以数组作为输入的 toArray 语法,但后来我切换到无参数版本,即我从: String[] myArray = myList.
我最近在使用某种网络方法时遇到了很多问题: void CheckGfiHelpdesks(string ticket, GfiCheck[] newHelpdeskChecks, GfiCheck[]
我在我的项目中使用 angular-filter 按页面对输出对象进行排序,问题是当我使用这样的语法时: {{key}} {{dziecko.rodzina}} {{dzi
Laravel 5.8 我懒惰地将用户加载到与 crmaccount 对象具有一对一关系的相关客户 这些模型正在工作,因此当我检索预先加载的实体时,它会显示所有嵌套关系。 一行之后,我对该对象使用了“
我有一个简单的问题。 这是我的代码,问题是当我运行一些表情符号时,它会将它们显示为?,因为它将表情符号切成两半。 angular.module('Joe.filters').filter("initi
我想我已经陷入困境。由于性能原因,我正在尝试利用Java parallelStream。 函数Specimen.pick()采样并返回Specimen的实例。 我想在替换池时使用parallelStr
我写了这段代码,这是一个评级系统。我想要发生的是,当你将鼠标悬停在一颗星星上时,它应该触发之前的星星。 每当我将鼠标悬停在星星上时,图片就会发生变化,但它之前的星星不会改变。
我是一名优秀的程序员,十分优秀!