Saya berada di bahagian atas kaedah pengawal:
namespace App\Http\AdminControllers;
public function signIn(Request $request) {
return redirect()->intended('Am/Index/index', $request);
}
Ini akan melompat ke kaedah indeks pengawal Indeks, tetapi kini masalahnya datang, bukannya melompat, program melaporkan ralat:
Object of class Illuminate\Http\Request could not be converted to int
Tetapi saya selalu menulis seperti ini sebelum ini... Saya tidak tahu mengapa saya mendapat ralat, saya hanya memajukan permintaan
Sila berikan saya pendapat anda, terima kasih semua
Sudah tentu anda salah
Mari kita lihat definisi intended
的定義
https://laravel.com/api/5.1/I...
RedirectResponse intended(string $default = '/', int $status = 302, array $headers = array(), bool $secure = null)
第一個參數(shù)是跳轉(zhuǎn)到的網(wǎng)址,默認(rèn) 首頁
第二個參數(shù)是 http 狀態(tài)碼,默認(rèn) 302,需要 int 類型,因為是重定向嘛
看你的使用方法,在第二個參數(shù)傳遞了 $request 對象,這個需要的參數(shù)不符合呀
所以報錯 could not be converted to int
https://laravel.com/api/5.1/I...# ????#
rrreee
namespace App\Http\AdminControllers;
use Illuminate\Http\Request; // 加上這一行導(dǎo)入這個類即可
public function signIn(Request $request) {
return redirect()->intended('Am/Index/index', $request);
}