【问题标题】:I am so new to Laravel/PHP and I cant find the error我对 Laravel/PHP 很陌生,我找不到错误
【发布时间】:2015-07-23 03:59:28
【问题描述】:

我有一个使用 Lavarel 设计的 CRM 系统。我想要做的是选择一些联系人,点击保存按钮(我必须在导出为 CSV 之前保存)。

但是,当我点击下载按钮后,我的联系人将不会导出到 CSV,并且我收到此错误:

Symfony\Component\Debug\Exception\FatalErrorException (E_ERROR) 调用未定义的方法 Symfony\Component\HttpFoundation\BinaryFileResponse::withCookie() 打开:/home/mirjamro/public_html/mr-admin.com/app/filters.php

Auth::logout(); return Redirect::to(URL::route('AdminShowLogin')); }
if(Auth::check()){
  $ckname=Auth::getRecallerName(); //Get the name of the cookie, where remember me expiration time is stored
  $ckval=Cookie::get($ckname); //Get the value of the cookie
  return $response->withCookie(Cookie::make($ckname,$ckval,1440)); //change the expiration time
}
});

我无法从服务器下载任何东西。

【问题讨论】:

  • 您在 BinaryFileResponse 中调用了 withCookie() 函数,但该函数尚未定义。
  • @edi9999 请在编辑问题时使用正确的代码块。
  • 提问时,尽量用恰当的语言尊重他人的眼睛和大脑。像第一次阅读一样重新阅读问题一两次,然后说其他人是否清楚地理解您的问题。

标签: php laravel


【解决方案1】:

从以下位置更改代码:

    return $response->withCookie(Cookie::make($ckname,$ckval,1440));

到:

    return Response::make($response)->withCookie(Cookie::make($ckname,$ckval,1440));

【讨论】:

    猜你喜欢
    • 2017-06-26
    • 2014-11-07
    • 1970-01-01
    • 2016-02-08
    • 2017-10-07
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    相关资源
    最近更新 更多