129 lines
2.1 KiB
PHP
129 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Model\Data;
|
|
|
|
use Phalcon\Mvc\Model;
|
|
use InvalidArgumentException;
|
|
|
|
class User extends Model
|
|
{
|
|
const STATUS_ACTIVE = 'Active';
|
|
const STATUS_DELETED = 'Deleted';
|
|
const STATUS_SUSPENDED = 'Suspended';
|
|
|
|
protected $id;
|
|
|
|
protected $username;
|
|
|
|
protected $email;
|
|
|
|
protected $status;
|
|
|
|
protected $password;
|
|
|
|
public function initialize()
|
|
{
|
|
$this->useDynamicUpdate(true);
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $id
|
|
* @return User
|
|
*/
|
|
public function setId($id)
|
|
{
|
|
$this->id = $id;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getUsername()
|
|
{
|
|
return $this->username;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $username
|
|
* @return User
|
|
*/
|
|
public function setUsername($username)
|
|
{
|
|
$this->username = $username;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getEmail()
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $email
|
|
* @return User
|
|
*/
|
|
public function setEmail($email)
|
|
{
|
|
$this->email = $email;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getStatus()
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
/**
|
|
* @param string $value
|
|
* @return User
|
|
*/
|
|
public function setStatus($value)
|
|
{
|
|
$allowed_values = array(
|
|
self::STATUS_ACTIVE,
|
|
self::STATUS_DELETED,
|
|
self::STATUS_SUSPENDED
|
|
);
|
|
|
|
if (!in_array($value, $allowed_values)) {
|
|
$msg = "Status '{$value}' is not a valid enum value'";
|
|
throw new InvalidArgumentException($msg);
|
|
}
|
|
|
|
$this->status = $value;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getPassword()
|
|
{
|
|
return $this->password;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $password
|
|
* @return User
|
|
*/
|
|
public function setPassword($password)
|
|
{
|
|
$this->password = $password;
|
|
return $this;
|
|
}
|
|
}
|