83 lines
2.7 KiB
PHP
83 lines
2.7 KiB
PHP
<?php namespace App\Models;
|
|
|
|
|
|
/*
|
|
|
|
CREATE TABLE IF NOT EXISTS `SIMs` (
|
|
`smIDsim` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Identificativo univoco della SIM telefonica',
|
|
`smNumero` varchar(16) NOT NULL COMMENT 'Numero telefonico della SIM',
|
|
`smPIN` varchar(16) NOT NULL COMMENT 'Pin della SIM',
|
|
`smPUK` varchar(16) NOT NULL COMMENT 'Puk della SIM',
|
|
`smDescrizione` text NOT NULL COMMENT 'Descrizione dell''articolo',
|
|
`smCredito` float NOT NULL DEFAULT 0 COMMENT 'Valore stimato del credito nella SIM',
|
|
`smCreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp di inserimento del record nel database',
|
|
`smUpdatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp in cui il record è stato aggiornato',
|
|
`smStato` enum('Disponibile','In uso','Scaduta') NOT NULL DEFAULT 'Disponibile' COMMENT 'Stato della SIM, riassume gli eventi',
|
|
`smDeletedAt` timestamp NULL DEFAULT NULL COMMENT 'Timestamp in cui il record è stato virtualmente cancellato (senza delete reale)',
|
|
PRIMARY KEY (`smIDsim`),
|
|
UNIQUE KEY `smIDsim` (`smIDsim`),
|
|
UNIQUE KEY `smNumero` (`smNumero`, `smDeletedAt`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tabella con tutte le SIM aziendali.';
|
|
|
|
Fields:
|
|
Tab: SIMs = ['smIDsim', 'smNumero', 'smPIN', 'smPUK', 'smDescrizione', 'smCredito', 'smCreatedAt', 'smUpdatedAt', 'smStato', 'smDeletedAt'];
|
|
|
|
*/
|
|
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
|
|
|
|
class SIMs_Model extends Model {
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
// Property
|
|
|
|
|
|
protected $table = 'SIMs';
|
|
protected $primaryKey = 'smIDsim';
|
|
|
|
protected $returnType = 'App\Entities\SIM';
|
|
//protected $returnType = 'array';
|
|
|
|
protected $allowedFields = ['smNumero', 'smPIN', 'smPUK', 'smDescrizione', 'smCredito', 'smStato'];
|
|
|
|
protected $useSoftDeletes = true;
|
|
protected $useTimestamps = true;
|
|
protected $createdField = 'smCreatedAt';
|
|
protected $updatedField = 'smUpdatedAt';
|
|
protected $deletedField = 'smDeletedAt';
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
// Events
|
|
|
|
|
|
//protected $beforeInsert = ['beforeInsert'];
|
|
//protected $afterInsert = ['afterInsert'];
|
|
//protected $beforeUpdate = ['beforeUpdate'];
|
|
//protected $afterUpdate = ['afterUpdate'];
|
|
//protected $beforeDelete = ['beforeDelete'];
|
|
//protected $afterDelete = ['afterDelete'];
|
|
//protected $afterFind = ['afterFind'];
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
// Methods
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
}//class SIMs_Model
|