golf_backend/app/Models/User_model.php
suseendhiran17 394f3a2f5b susee
2023-06-10 16:55:09 +05:30

47 lines
1.2 KiB
PHP

<?php namespace App\Models;
use CodeIgniter\Model;
class User_model extends Model
{
protected $table = 'users';
protected $primaryKey = 'id';
protected $allowedFields = ['role','name', 'mobile', 'profile' , 'email', 'password', 'address' , 'city' , 'state' , 'country' , 'pincode' , 'new_mail' , 'is_active' ,'created_at','updated_at'];
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('users');
$builder -> select("id,mobile,email,password,is_active");
$builder -> where('email',$email);
$result = $builder->get();
if(count($result->getResultArray()) ==1)
{
return $result->getRowArray();
}else{
return false;
}
}
}