如果当前状态X,则阻止状态更新

I have a function to update a post status as below,

public function update_post()
    {
        $this->is_allowed('api_$customer_id_driver_task_update', false);


        $this->form_validation->set_rules('status', 'Status', 'trim|required|max_length[255]');

        if ($this->form_validation->run()) {

            $save_data = [
                'status' => $this->input->post('status'),
            ];

            $save_people_driver_task = $this->model_api_people_driver_task->change($this->post('task_id'), $save_data);

            if ($save_people_driver_task) {
                $this->response([
                    'status'    => true,
                    'message'   => 'Your data has been successfully updated into the database'
                ], API::HTTP_OK);

            } else {
                $this->response([
                    'status'    => false,
                    'message'   => cclang('data_not_change')
                ], API::HTTP_NOT_ACCEPTABLE);
            }

        } else {
            $this->response([
                'status'    => false,
                'message'   => validation_errors()
            ], API::HTTP_NOT_ACCEPTABLE);
        }
    }

the status it self is assigned, onstart, completed. What i want to do is if the status already onstart, the script will block the user to change status revert back to assigned and also if status already completed user cannot change the status to onstart or assigned. is it possible to do this?

Already try something like this but no luck

if($result && $result[0]->status =='assigned') 
{ 
    $this->db->set('status','onstarts'); 
}
else
{ 
    $this->db->set('status','completed'); 
}