0
Laravel 5.3。我得到一個表(用戶表)primaryKey的錯誤值,但我正確地得到它。這很奇怪。這裏是我的代碼Laravel 5.3無法訪問PrimeraKey對象
protected $table = 'users_tbl';
protected $primaryKey = "email";
控制器:
$user = User::find('[email protected]');
dd($user);
#table: "users_tbl"
#primaryKey: "email"
#fillable: array:8 [▶]
#hidden: array:2 [▶]
#connection: null
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:15 [▼
"email" => "[email protected]"
"register" => "1892"
"section" => "GO"
"turn" => 92
...
輸出的郵件正常,但是當我通過訪問對象得到0。但是其餘屬性都ok:
echo $user->email;
echo "<br>";
echo $user->register;
echo "<br>";
echo $user->section;
echo "<br>";
echo $user->turn;
echo "<br>";
exit;
輸出
0
1892
GO
92
有什麼想法發生了什麼?
感謝的人我變得瘋狂。在laravel文檔中非常清楚。但我沒有在其他laravel的項目中設置它們,並且它們工作正常。始終爲5.2或更低版本。 – user3604672