Stat.php 1.12 KB
<?php
namespace App\Model\Entity;

use Cake\ORM\Entity;

/**
 * Stat Entity
 *
 * @property string $year
 * @property int $user_id
 * @property \Cake\I18n\FrozenTime|null $last_login_time
 * @property \Cake\I18n\FrozenTime|null $last_logout_time
 * @property int $connex_nb
 * @property int $connex_dur
 *
 * @property \App\Model\Entity\User $user
 */
class Stat extends Entity
{
    /**
     * Fields that can be mass assigned using newEntity() or patchEntity().
     *
     * Note that when '*' is set to true, this allows all unspecified fields to
     * be mass assigned. For security purposes, it is advised to set '*' to false
     * (or remove it), and explicitly make individual fields accessible as needed.
     *
     * @var array
     */
    protected $_accessible = [
        'last_login_time' => true,
        'last_logout_time' => true,
        'connex_nb' => true,
        'connex_dur' => true,
        'user' => true
    ];
    
    
    // Propriété virtuelle : champ généré par calcul
    // $e->connexDurAvg
    protected function _getConnexDurAvg() { 
        return (int)($this->connex_dur_tot / $this->connex_nb);
    }
}