php - Laravel reports an error when passing $request parameter?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-27 17:42:18
0
2
601

I am at the top of the controller method:

namespace App\Http\AdminControllers;
public function signIn(Request $request) {
    return redirect()->intended('Am/Index/index', $request);
}

This will jump to the index method of the Index controller, but now the problem is coming. Instead of jumping, the program reports an error:

Object of class Illuminate\Http\Request could not be converted to int

But I have always written like this before...I don’t know why I reported an error. I just forwarded the request.
Please give me your opinions, thank you all.

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
洪涛

Of course you are not right
Let’s take a look at the definition of intended
https://laravel.com/api/5.1/I...

RedirectResponse intended(string $default = '/', int $status = 302, array $headers = array(), bool $secure = null)
  • The first parameter is the URL to jump to, the default is homepage

  • The second parameter is the http status code, the default is 302, and the int type is required because it is a redirection

Looking at your usage method, you passed the $request object in the second parameter. This required parameter does not meet the requirements

So the error could not be converted to int is that it cannot be converted into int type

迷茫
namespace App\Http\AdminControllers;
use Illuminate\Http\Request; // 加上这一行导入这个类即可
public function signIn(Request $request) {
    return redirect()->intended('Am/Index/index', $request);
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template