first commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class UserModel extends Model
|
||||
{
|
||||
protected $table = 'users';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'email',
|
||||
'password',
|
||||
'name',
|
||||
'phone',
|
||||
'avatar',
|
||||
// Поля для верификации email
|
||||
'verification_token',
|
||||
'email_verified',
|
||||
'verified_at'
|
||||
];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Хеширование пароля перед вставкой
|
||||
protected $beforeInsert = ['hashPassword'];
|
||||
protected $beforeUpdate = ['hashPassword'];
|
||||
|
||||
protected function hashPassword(array $data)
|
||||
{
|
||||
if (isset($data['data']['password'])) {
|
||||
$data['data']['password'] = password_hash($data['data']['password'], PASSWORD_DEFAULT);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user