简体   繁体   中英

update multiple Records at a time using checkbox laravel

I want to update multiple records statuses or delete.

Status is: accept, reject, pending.

so want to give checkbox to the user for select multiple records and dropdown for choose status want to update records at a time,

and also want to give the delete option on the dropdown to delete mass records at a time

public function updateRecords(Request $request) {
   $recordIds = $request->get('recordIds');
   $newStatus = $request->get('newStatus');
   RecordModel::whereIn('id', $recordIds)->update(['status' => $newStatus]);
}
public function deleteRecords(Request $request) {
   $recordIds = $request->get('recordIds');
   RecordModel::whereIn('id', $recordIds)->delete();
}

I answered a similar question few days back. Look Update status of each dynamic row using checkbox .

Hope it helps. Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM