【问题标题】:Need explanation on Maatwebsite Excel "From View" code需要 Maatwebsite Excel“从视图”代码的解释
【发布时间】:2018-06-25 10:10:34
【问题描述】:

在研究如何使用集合 + HTML 视图将表列表数据导入 excel 文件时,我遇到了maatwebsite/excel 包。我设法按照文档导入了 excel。但是,我对作者使用的代码语法并不熟悉。在this link,作者定义了一个函数view(),如下代码所示:

public function view(): View
{
    return view('exports.invoices', [
        'invoices' => Invoice::all()
    ]);
}

我不熟悉 view(): View 语法。有人可以指导我找到适当的文档吗?告诉我如何在 Netbeans 中解决这个问题(见下面的截图)? Screenshot of Netbeans error

请记住,代码本身运行正常且没有问题。我可以按照我的要求下载 excel 文件。

使用:Laravel 5.6、PHP 7.1.17、NetBeans 8.0.2、maatwebsite/excel 3.0

对此的任何信息表示赞赏。提前致谢。

【问题讨论】:

    标签: netbeans-8 maatwebsite-excel


    【解决方案1】:

    在 PHP 7.0 及更高版本中,我们可以定义返回类型。例如。

    function sum(): int {
    // function body.
    
    }
    

    同样适用:

    公共函数view():查看

    这一行说函数 view() 只返回 View 类对象。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 2020-02-20
    • 1970-01-01
    相关资源
    最近更新 更多