我需要在我的系统中存档数据。我使用Mysql和Laravel 5.3来开发这个系统。现在我创建了删除选定的行。
EmployeeController.php
public function deleteEmployeeEntries($id, Request $request) {
$test = $this->Employee->delete($id);
if($test) {
$data['message'] = 'Record has been deleted successfully!';
} else {
$data['error'] = "Couldn't delete the user";
}
return $data;
}
EmployeeRepository.php
public function delete($id) {
$data=$this->model->where('id','=',$id)->delete();
return $data;
}
但是我需要归档。我在database.how中维护状态列。我将状态1更改为0 ??
答案 0 :(得分:1)
如果要更新某个表中的状态,则需要使用update()
Model::where('id', 5)->update(['status' => 0]);
或save()
$model = Model::find(5);
$model->status = 0;
$model->save();