public function initialize() { parent::initialize(); $this->belongsTo('user_id', __NAMESPACE__ . '\\Users', 'id', array('alias' => 'User', 'foreignKey' => true)); // Do garbage collection if (mt_rand(1, 100) === 1) { $this->delete_expired(); } // This object has expired if (property_exists($this, 'expires') && $this->expires < time()) { $this->delete(); } }
public function initialize() { parent::initialize(); $this->belongsTo('banner_id', 'App\\Models\\Banners', 'id', array('alias' => 'banner')); $this->belongsTo('zone_id', 'App\\Models\\Zones', 'id', array('alias' => 'zone')); }