<?php namespace App\Models;

use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;

class UserModel extends Model
{
    protected $table = 'users';

    protected $allowedFields = ['userID','firstName','secondName','surName','password',
      'title','qualification','specialization','yearsOfExperience',
      'phone','email','cv','userType','classType','coursesName', 'course_id', 'gender','organisationName','nationality',
      'accomodation','pickAirport','employerName','employerPhone','employerEmail',
      'comment','userStatus','dateCreated','createdBy','dateModified','modifiedBy'  ];

      public function getUserLogin($email,$password){

        $db      = \Config\Database::connect();
        $builder = $db->table('users');

        $builder->select('userID,firstName,secondName,email,userType');

        $query = $builder->getWhere(['email' => $email,'password' => $password]);

        return $query->getRow();

      }
      public function updateUser($userId,$data){
          
         
    $db = \Config\Database::connect();
    $builder = $db->table('users');
    $builder->where('userID', 29);
    $res = $res = $builder->update([
        'firstName' => $data['firstName'],
        'secondName' => $data['secondName'],
        'surName' => $data['surName'],
        'title' => $data['title'],
        'qualification' => $data['qualification'],
        'specialization' => $data['specialization'],
        'classType' => $data['classType'],
        'coursesName' => $data['coursesName'],
        'yearsOfExperience' => $data['yearsOfExperience'],
        'phone' => $data['phone'],
        'email' => $data['email'],
        'userType' => $data['userType'],
        'gender' => $data['gender'],
        'organisationName' => $data['organisationName'],
        'nationality' => $data['nationality'],
        'accomodation' => $data['accomodation'],
        'pickAirport' => $data['pickAirport'],
        'employerName' => $data['employerName'],
        'employerPhone' => $data['employerPhone'],
        'employerEmail' => $data['employerEmail'],
        'comment' => $data['comment'],
        'createdBy' => $data['createdBy'],
    ]);


    return $res;

      }

}
