You could check your database before you insert, to ensure there is no proposal from that user for that particular job. Here's a brief example that you could add to the start of your add_job_proposal_from_provider($obj)
method:
$this->db->from('job_proposal');
$this->db->where('job_id', $obj['job_id']);
$this->db->where('provider_id', $this->auth_model->get_user_id());
$result = $this->db->get();
if ($result->num_rows() > 0) {
// Set some error message?
return;
}
Alternatively, you could set a UNIQUE
index in your database across the job_id
and provider_id
fields. An example in MySQL is:
ALTER TABLE job_proposal ADD UNIQUE INDEX(provider_id, job_id);