|
- <?php
-
- namespace App\Models;
-
- use CodeIgniter\Model;
-
- class SurveyUserModel extends Model
- {
- protected $table = 'survey_user';
- protected $useTimestamps = true;
-
- protected $allowedFields = ['survey_id', 'user_id'];
-
- protected $validationRules = [
- 'survey_id' => 'required',
- 'user_id' => 'required',
- ];
-
-
- public function alreadyAnswered($surveyId, $userId)
- {
- return $this->where([
- 'survey_id' => $surveyId,
- 'user_id' => $userId,
- ])->countAllResults();
- }
-
-
- public function getEncuestasContestadas()
- {
- return $this
- ->join('survey_set', 'survey_user.survey_id = survey_set.id')
- ->join('users', 'survey_user.user_id = users.id')
- ->join('prestador', 'users.idprestador = prestador.idprestador')
- ->findAll();
- }
- }
|