47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class Member_model extends Model
|
|
{
|
|
protected $table = 'member';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $allowedFields = ['name', 'mobile','email','username', 'password', 'address' , 'city' , 'state' , 'country' , 'pincode' , 'is_email_verifyed' , 'created_by','updated_by'];
|
|
|
|
protected $beforeInsert = ['beforeInsert'];
|
|
protected $beforeUpdate = ['beforeUpdate'];
|
|
|
|
protected function beforeInsert(array $data){
|
|
$data= $this->passwordHash($data);
|
|
return $data;
|
|
}
|
|
|
|
protected function beforeUpdate(array $data){
|
|
$data= $this->passwordHash($data);
|
|
return $data;
|
|
}
|
|
|
|
protected function passwordHash(array $data)
|
|
{
|
|
if(isset($data['data']['password']))
|
|
$data['data']['password'] = password_hash($data['data']['password'],PASSWORD_DEFAULT);
|
|
return $data;
|
|
}
|
|
public function verifyEmail($email)
|
|
{
|
|
|
|
$builder = $this->db->table('member');
|
|
$builder -> select("id,mobile,email,password");
|
|
$builder -> where('email',$email);
|
|
$result = $builder->get();
|
|
if(count($result->getResultArray()) ==1)
|
|
{
|
|
return $result->getRowArray();
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
} |