-2

I need to archive data in my system.I used Mysql and Laravel 5.3 to develop this system.Now i created to delete selected row.

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;
}

But i need to archive.I maintain the status column in database.how i change the status 1 to 0 ??

Manoj Sharma
  • 1,467
  • 2
  • 13
  • 20
RuwanthaSameera
  • 113
  • 1
  • 12

1 Answers1

1

If you want to update status in some table, you need to use update()

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

Or save()

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

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

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279