简体   繁体   English

使用复选框 laravel 一次更新多个记录

[英]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,所以想为 select 多条记录和下拉选择状态的用户提供复选框想要一次更新记录,

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!干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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