我有这段代码
0 observations created
当我尝试class DonorsController extends Controller
{
//Some code
public function donorAddSave(Request $request){
if ($request->file('DonorPhoto')->isValid()) {
$destinationPath = 'uploads'; // upload path
$DonorPhotoURL = date_timestamp_get(date_create()).'.'.$request->file('DonorPhoto')->guessExtension();
$request->file('DonorPhoto')->move($destinationPath,$DonorPhotoURL);
}
$request->offsetSet('UserID',1);
$request->offsetSet('DonorPhotoURL','/'.$destinationPath.'/'.$DonorPhotoURL);
if(!$request->has('DonorPrefix')){
$request->offsetSet('DonorPrefix', 'Mx.');
}
$donor = \App\Donor::create($request->all());
return redirect('/donor/'.$donor->DonorID);
}
}
查看return $request->all()
,DonorPrefix
和UserID
的值是否已存储在请求数组中时,返回的JSON似乎拥有所有这三个变量。
DonorPhotoURL
但是,当我尝试返回{
"DonorCitizenID": "1000000000000",
"DonorPrefix": "คุณ",
...
"UserID": 1,
"DonorPhotoURL": "/uploads/1465963777.png",
"DonorPhoto": {}
}
(捐赠者的对象)时,$donor
定义了其值,$donor = \App\Donor::create($requests->all());
和UserID
的值未存储,但DonorPhotoURL
确实具有DonorPrefix
的值。以下是Mx
的JSON:
$donor
({
"DonorCitizenID": "1000000000000",
"DonorPrefix": "คุณ",
...
"updated_at": "2016-06-15 04:16:47.000",
"created_at": "2016-06-15 04:16:47.000",
"DonorID": 39
}
表示为清洁代码段设置的一些数据
我确信数据库本身的列名为...
和DonorPhotoURL
,但它仍然不存储值。