Your IP : 216.73.217.64


Current Path : /home3/gp97/courrierscolo.97gp.net/modules/entities/Models/
Upload File :
Current File : //home3/gp97/courrierscolo.97gp.net/modules/entities/Models/EntitiesModelAbstract.php

<?php

/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/

/**
* @brief Entities Model
* @author dev@maarch.org
* @ingroup entities
*/

namespace Entities\Models;

require_once 'apps/maarch_entreprise/services/Table.php';

class EntitiesModelAbstract extends \Apps_Table_Service
{

    public static function getByEmail(array $aArgs = [])
    {
        static::checkRequired($aArgs, ['email']);
        static::checkString($aArgs, ['email']);

        $aReturn = static::select([
            'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
            'table'     => ['entities'],
            'where'     => ['email = ? and enabled = ?'],
            'data'      => [$aArgs['email'], 'Y'],
            'limit'     => 1,
        ]);

        return $aReturn;
    }

    public static function getByUserId(array $aArgs = [])
    {
        static::checkRequired($aArgs, ['user_id']);
        static::checkString($aArgs, ['user_id']);

        $aReturn = static::select([
            'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
            'table'     => ['users_entities'],
            'where'     => ['user_id = ? and primary_entity = ?'],
            'data'      => [$aArgs['user_id'], 'Y'],
            'limit'     => 1,
        ]);

        return $aReturn;
    }
}