当我将用户信息插入我的应用程序时,我使用以下代码:
$userId = Auth::user()->user_id;
$newUserInfo = UserInfo::create([
'u_info_id' => $userId,
'u_first_name' => Input::get('u_first_name'),
'u_last_name' => Input::get('u_last_name'),
'u_phone_number' => Input::get('u_phone_number'),
'u_address' => Input::get('u_address'),
'u_state_id' => Input::get('u_state_id'),
'u_city_id' => Input::get('u_city_id'),
'u_zip' => Input::get('u_zip')
]);
但我不能这样做'u_info_id' => $userId
,因为这会迫使我为群发作业提供 u_info_id 。
所以我的问题是,我怎样才能使用'u_info_id' => $userId
而不使 u_info_id 填充进行质量分配。我不希望用户能够编辑 u_info_id 。该字段应插入后端。
或者,在使用laravel - > fill()时,我只需要设置可填充质量分配吗?
答案 0 :(得分:0)
//输入验证
$newUserInfo = new UserInfo();
$newUserInfo->u_info_id = $userId;
$newUserInfo->u_first_name = Input::get('u_first_name');
$newUserInfo->u_last_name = Input::get('u_last_name');
$newUserInfo->u_phone_number = Input::get('u_phone_number');
$newUserInfo->u_address = Input::get('u_address');
$newUserInfo->u_state_id = Input::get('u_state_id');
$newUserInfo->u_city_id = Input::get('u_city_id');
$newUserInfo->u_zip = Input::get('u_zip');
$newUserInfo->save();