Issue in accessing a supposedly disabled function in CODEIGNITER

后端 未结 1 1640
南方客
南方客 2021-01-29 15:31

I realized a very significant problem in my application. It\'s about hire function.What happens is even an applicant has already been hired, if the client clicks the reject butt

1条回答
  •  清歌不尽
    2021-01-29 16:20

    You can check your database to ensure the proposal has not already been accepted with something along these lines. If you want to do it for both instances (accept, and reject), perhaps you could move the check into an additional function that checks to see if a proposal is already in an 'ending' state (i.e. Accepted or Rejected).

    A sample addition to your reject_job_proposal method could be...

    public function reject_job_proposal ($job_id, $provider_id, $proposal_id) 
    {
        $this->db->select('status');
        $this->db->from('job_proposal');
        $this->db->where('id', $proposal_id);
        $query  = $this->db->get();
        $result = $query->row();
        if ($result->status === 'Accepted') {
            // Throw error message, e.g. 'Sorry, this job has been accepted!'
            return;
        }
    
        ...
    }
    

    0 讨论(0)
提交回复
热议问题