Archived
1
0
Fork 0

app/models/Data/User.php: implement status column (renamed from deleted that did not exist in db).

This commit is contained in:
Henrik Hautakoski 2018-03-20 23:12:59 +01:00
parent 279e6a30c1
commit 3e0e526f4e

View file

@ -3,16 +3,21 @@
namespace Model\Data; namespace Model\Data;
use Phalcon\Mvc\Model; use Phalcon\Mvc\Model;
use InvalidArgumentException;
class User extends Model class User extends Model
{ {
const STATUS_ACTIVE = 'Active';
const STATUS_DELETED = 'Deleted';
const STATUS_SUSPENDED = 'Suspended';
protected $id; protected $id;
protected $username; protected $username;
protected $email; protected $email;
protected $deleted; protected $status;
protected $password; protected $password;
@ -76,20 +81,31 @@ class User extends Model
} }
/** /**
* @return mixed * @return string
*/ */
public function getDeleted() public function getStatus()
{ {
return $this->deleted; return $this->status;
} }
/** /**
* @param mixed $deleted * @param string $value
* @return User * @return User
*/ */
public function setDeleted($deleted) public function setStatus($value)
{ {
$this->deleted = $deleted; $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 $this;
} }