donation/app/Models/Donor_model.php
2020-12-21 11:44:46 +05:30

60 lines
1.6 KiB
PHP

<?php namespace App\Models;
use CodeIgniter\Model;
class Donor_model extends Model
{
protected $table = 'user_management';
protected $primaryKey = 'id';
protected $allowedFields = ['name', 'phone','email','pan', 'address','country','state','city','pin_code','date_of_birth','gender', 'org_name','gstin','foreign_key', 'password','signature','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('user_management');
$builder -> select("id,phone,email,password");
$builder -> where('email',$email);
$result = $builder->get();
if(count($result->getResultArray()) ==1)
{
return $result->getRowArray();
}else{
return false;
}
}
// protected $returnType = 'array';
// protected $useSoftDeletes = true;
// protected $useTimestamps = false;
// protected $createdField = 'created_at';
// protected $updatedField = 'updated_at';
// protected $deletedField = 'deleted_at';
// protected $validationRules = [];
// protected $validationMessages = [];
// protected $skipValidation = false;
}