反正有一个模型传递雄辩的laravel的updateOrCreate方法吗?我当前的代码运行正常,其中我将数组传递给updateOrCreate方法。
$ud = UserDetail::updateOrCreate(
['user_id' => $user->id],
[
'father_name' => $request['fname'], 'dob' => $request['dob'],
'contact_no' => $request['contactNumber'], 'img_url' => $url,
'postal_address' => $request['postalAddress'],
'permanant_address' => $request['permanantAddress'],
'gender' => $request['gender'], 'religion' => $request['religion'],
'marital_status' => $request['maritalStatus'],
'district_id' => $request['district'], 'profile_status' => $status]);
我多次使用updateOrCreate方法。因此,我想一次创建一个模型,将这些值分配给模型,然后将其传递给updateOrCreate方法,而不是传递大数组。
//Create model and assign values
$user_d = new UserDetail;
$user_d->father_name = $request['fname'];
$user_d->dob = $request['dob'];
//pass the model to updateOrCreate method
$ud = UserDetail::updateOrCreate(
['user_id' => $user->id], $user_d );
答案 0 :(得分:2)
您可以使用attributesToArray
方法
implicit class DataFrameExtension(private val dataFrame: DataFrame) extends Serializable { ..... // Custom methods to perform some computations }