UserModel.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Models;
  3. use CodeIgniter\Model;
  4. // Modelo que representa la tabla de usuarios.
  5. class UserModel extends Model
  6. {
  7. protected $table = 'usuarios';
  8. // protected $primaryKey = 'id';
  9. protected $primaryKey = 'idUsuario';
  10. // protected $useAutoIncrement = true;
  11. protected $useAutoIncrement = false;
  12. protected $returnType = 'array';
  13. protected $useSoftDeletes = false;
  14. protected $protectFields = true;
  15. protected $allowedFields = ['correo', 'idRol', 'nombre', 'contrasena', 'estatus'];
  16. protected bool $allowEmptyInserts = false;
  17. protected bool $updateOnlyChanged = true;
  18. protected array $casts = [];
  19. protected array $castHandlers = [];
  20. // Dates
  21. protected $useTimestamps = false;
  22. protected $dateFormat = 'datetime';
  23. protected $createdField = 'created_at';
  24. protected $updatedField = 'updated_at';
  25. protected $deletedField = 'deleted_at';
  26. // Validation
  27. protected $validationRules = [];
  28. protected $validationMessages = [];
  29. protected $skipValidation = false;
  30. protected $cleanValidationRules = true;
  31. // Callbacks
  32. protected $allowCallbacks = true;
  33. protected $beforeInsert = [];
  34. protected $afterInsert = [];
  35. protected $beforeUpdate = [];
  36. protected $afterUpdate = [];
  37. protected $beforeFind = [];
  38. protected $afterFind = [];
  39. protected $beforeDelete = [];
  40. protected $afterDelete = [];
  41. // Relaciona la tabla de roles de los usuarios.
  42. public function role()
  43. {
  44. return $this->join('roles', 'usuarios.idRol = roles.idRol', 'inner');
  45. }
  46. }