This is from the last question that I asked..
I have a membership table
Schema::create('role_memberships', function (Blueprint $table) {
$table->increments('id');
$table->integer('role_id');
$table->string('MembershipName');
$table->text('MembershipValue');
$table->timestamps();
});
I have two rows data with same role_id and I want to update two rows This is my controller
$updateArray = [['MembershipValue' => $request->PostAdMaxImage],
['MembershipValue' => $request->PostAdExpiredDay]];
DB::table('role_memberships')->where('role_id', $id)-
>whereIn('role_id', $role->pluck('id'))->update($updateArray);
when I tried to update, I got an error array to string conversion..
foreach($updateArray as $array){ DB::table('role_memberships')->where('role_id', $id)->whereIn('role_id', $role->pluck('id'))->update($array); }
id = 1, role_id = 1, I do $request->PostAdMaxImage = 'hello'
id = 2, role_id = 1, I do $request->PostAdExpiredDay = 'world'
. then, I save and re-open again.. my value of PostAdMaxImage and PostAdExpiredDay turn into 'world', in the other word, it only take the last value