- First commit of ulmus user package
This commit is contained in:
commit
d7010b6c3b
4 files changed
+253
No files matched your search
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\User\Entity;
|
||||
|
||||
use Ulmus\Entity\Field\Datetime;
|
||||
|
||||
class User {
|
||||
|
||||
/**
|
||||
* @Id('readonly' => true)
|
||||
*/
|
||||
public int $id;
|
||||
|
||||
/**
|
||||
* @Field("size" => 35, "name" => "first_name")
|
||||
*/
|
||||
public ? string $firstName;
|
||||
|
||||
/**
|
||||
* @Field("size" => 35, "name" => "last_name")
|
||||
*/
|
||||
public ? string $lastName;
|
||||
|
||||
/**
|
||||
* @Field("size" => 150)
|
||||
*/
|
||||
public string $email;
|
||||
|
||||
/**
|
||||
* @Field("size" => 150)
|
||||
*/
|
||||
public ? string $address;
|
||||
|
||||
/**
|
||||
* @Field("size" => 15, 'name' => "zip_code")
|
||||
*/
|
||||
public ? string $zipCode;
|
||||
|
||||
/**
|
||||
* @Field("size" => 45)
|
||||
*/
|
||||
public ? string $province;
|
||||
|
||||
/**
|
||||
* @Field("size" => 3)
|
||||
*/
|
||||
public ? string $country;
|
||||
|
||||
/**
|
||||
* @Field("size" => 15)
|
||||
*/
|
||||
public ? string $phone;
|
||||
|
||||
/**
|
||||
* @Field("size" => 15)
|
||||
*/
|
||||
public ? string $ext;
|
||||
|
||||
/**
|
||||
* @Field("size" => 15)
|
||||
*/
|
||||
public ? string $mobile;
|
||||
|
||||
/**
|
||||
* @Field("size" => 255)
|
||||
*/
|
||||
public ? string $username;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $password;
|
||||
|
||||
/**
|
||||
* @UpdatedAt('readonly' => true, 'name' => "updated_at")
|
||||
*/
|
||||
public ? Datetime $updatedAt;
|
||||
|
||||
/**
|
||||
* @CreatedAt('readonly' => true, 'name' => "created_at")
|
||||
*/
|
||||
public Datetime $createdAt;
|
||||
|
||||
public bool $logged = false;
|
||||
|
||||
public function setPassword($password) : self
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this->hashPassword();
|
||||
}
|
||||
|
||||
public function hashPassword() : self
|
||||
{
|
||||
$this->password = password_hash($this->password, PASSWORD_DEFAULT);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function verifyPassword(string $password) : bool
|
||||
{
|
||||
return password_verify($password, $this->password );
|
||||
}
|
||||
|
||||
public function fullname() : string
|
||||
{
|
||||
return trim( ( $this->firstName ?? "" ) . " " . ( $this->lastName ?? "" ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user