我想归档数据。如何在laravel 5.3中进行归档?

时间:2017-01-05 06:19:16

标签: php mysql laravel

我需要在我的系统中存档数据。我使用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 ??

1 个答案:

答案 0 :(得分:1)

如果要更新某个表中的状态,则需要使用update()

Model::where('id', 5)->update(['status' => 0]);

save()

$model = Model::find(5);
$model->status = 0;
$model->save();

https://laravel.com/docs/5.3/eloquent#updates