Files
CSiCoDB2/app/Models/CSiCoCars_Model.php
T
2026-05-06 11:04:41 +02:00

82 lines
2.8 KiB
PHP

<?php namespace App\Models;
/*
CREATE TABLE IF NOT EXISTS `CSiCoCars` (
`caIDcar` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Identificativo univoco del veicolo',
`caTarga` varchar(10) NOT NULL COMMENT 'Targa del veicolo',
`caDescrizione` text NOT NULL COMMENT 'Descrizione del veicolo',
`caDataAssicurazione` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Prossima data di scadenza dell''assicurazione del veicolo',
`caTipoGomme` enum('Invernali','Estive','4Stagioni') NOT NULL DEFAULT '4Stagioni' COMMENT 'Tipologia di pneumatici in dotazione al veicolo',
`caCreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp di inserimento del record nel database',
`caUpdatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp in cui il record è stato aggiornato',
`caStato` enum('Disponibile','Occupata','Dismessa') NOT NULL DEFAULT 'Disponibile' COMMENT 'Stato della macchina, riassume gli eventi',
`caDeletedAt` timestamp NULL DEFAULT NULL COMMENT 'Timestamp in cui il record è stato virtualmente cancellato (senza delete reale)',
PRIMARY KEY (`caIDcar`),
UNIQUE KEY `caIDcar` (`caIDcar`),
UNIQUE KEY `caTarga` (`caTarga`, `smDeletedAt`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='Tabella con tutte le macchine della CSiCo.';
Fields:
Tab: CSiCoCars = ['caIDcar', 'caTarga', 'caDescrizione', 'caDataAssicurazione', 'caTipoGomme', 'caCreatedAt', 'caUpdatedAt', 'caStato', 'caDeletedAt'];
*/
use CodeIgniter\Model;
class CSiCoCars_Model extends Model {
//--------------------------------------------------------------------
// Property
protected $table = 'CSiCoCars';
protected $primaryKey = 'caIDcar';
protected $returnType = 'App\Entities\CSiCoCar';
//protected $returnType = 'array';
protected $allowedFields = ['caTarga', 'caDescrizione', 'caDataAssicurazione', 'caTipoGomme', 'caStato'];
protected $useSoftDeletes = true;
protected $useTimestamps = true;
protected $createdField = 'caCreatedAt';
protected $updatedField = 'caUpdatedAt';
protected $deletedField = 'caDeletedAt';
//--------------------------------------------------------------------
// Events
//protected $beforeInsert = ['beforeInsert'];
//protected $afterInsert = ['afterInsert'];
//protected $beforeUpdate = ['beforeUpdate'];
//protected $afterUpdate = ['afterUpdate'];
//protected $beforeDelete = ['beforeDelete'];
//protected $afterDelete = ['afterDelete'];
//protected $afterFind = ['afterFind'];
//--------------------------------------------------------------------
// Methods
//--------------------------------------------------------------------
}//class CSiCoCars_Model