php artisan 不起作用 [错误异常] 未定义的偏移量:0 在 laravel


php artisan doesnt work [ErrorException] Undefined offset: 0 in laravel

当我尝试运行php artisan时,我给出了错误

 [Error Exception]     
 Undefined offset: 0

当我运行composer installcomposer update时,我收到此错误

Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]  
  Error Output:   

我安装了所有扩展,运行composer dumpautoload但仍然收到此错误。 问题出在这个当前的 procjet(我创建了另一个 Laravel 项目,它工作正常)

最后我发现在服务提供商中,在引导方法中,有返回 false 的数据库查询,因此不存在索引为 0 的 array(我放置数据库查询结果的位置)

$result[0]->title // <---doesnt exist($result is empty)