donation/app/Models/UsersModel.php
2024-02-08 09:04:38 +05:30

31 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class UsersModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'user_id';
protected $allowedFields = ['user_id','user_name','email','first_name','last_name','password','branch_id','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','created_by','updated_by'];
public function saveData($data, $id = null)
{
if ($id === null) {
// Insert new record
return $this->insert($data);
} else {
// Update existing record
return $this->update($id, $data);
}
}
public function getOrganizationBranches($businessId)
{
// Assuming your branches table is named 'branches'
$db = db_connect();
$builder = $db->table('business_branches');
$branches = $builder->where('business_id', $businessId)->get()->getResultArray();
return $branches;
}
}