You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Models;
  3. use CodeIgniter\Model;
  4. class SurveyUserModel extends Model
  5. {
  6. protected $table = 'survey_user';
  7. protected $useTimestamps = true;
  8. protected $allowedFields = ['survey_id', 'user_id'];
  9. protected $validationRules = [
  10. 'survey_id' => 'required',
  11. 'user_id' => 'required',
  12. ];
  13. public function alreadyAnswered($surveyId, $userId)
  14. {
  15. return $this->where([
  16. 'survey_id' => $surveyId,
  17. 'user_id' => $userId,
  18. ])->countAllResults();
  19. }
  20. }