ProductModel.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Models;
  3. use CodeIgniter\Model;
  4. // Modelo que representa la tabla de productos.
  5. class ProductModel extends Model
  6. {
  7. protected $table = 'productos';
  8. // protected $primaryKey = 'id';
  9. protected $primaryKey = 'idProducto';
  10. protected $useAutoIncrement = true;
  11. protected $returnType = 'array';
  12. protected $useSoftDeletes = false;
  13. protected $protectFields = true;
  14. protected $allowedFields = ['nombre', 'precio', 'cantidad', 'estatus'];
  15. protected bool $allowEmptyInserts = false;
  16. protected bool $updateOnlyChanged = true;
  17. protected array $casts = [];
  18. protected array $castHandlers = [];
  19. // Dates
  20. // protected $useTimestamps = false;
  21. protected $useTimestamps = true;
  22. protected $dateFormat = 'datetime';
  23. // protected $createdField = 'created_at';
  24. protected $createdField = 'fecha_registro';
  25. // protected $updatedField = 'updated_at';
  26. protected $updatedField = 'fecha_modificacion';
  27. protected $deletedField = 'deleted_at';
  28. // Validation
  29. protected $validationRules = [];
  30. protected $validationMessages = [];
  31. protected $skipValidation = false;
  32. protected $cleanValidationRules = true;
  33. // Callbacks
  34. protected $allowCallbacks = true;
  35. protected $beforeInsert = [];
  36. protected $afterInsert = [];
  37. protected $beforeUpdate = [];
  38. protected $afterUpdate = [];
  39. protected $beforeFind = [];
  40. protected $afterFind = [];
  41. protected $beforeDelete = [];
  42. protected $afterDelete = [];
  43. }