the_mechanic/app/Models/UsersModel.php
2024-09-25 09:12:05 +05:30

46 lines
2.1 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class UsersModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'user_id';
protected $allowedFields = ['user_id','email','name','business_id','branch_id','role','password','mobile_no','isactive'];
public function getUserById($user_id) {
return $this->db->table('users')->where('user_id', $user_id)->get()->getRowArray();
}
public function dashboard_live_data($logged_user_branch_id)
{
$this->select('job_card.*, vehicle.reg_no, vehicle.make, vehicle.colour, vehicle.model, make.make as bike_name, model.model_name as bike_modal_name');
$this->from('job_card');
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
$this->join('make', 'make.make_id = vehicle.make', 'left');
$this->join('model', 'model.model_id = vehicle.model', 'left');
$this->where('job_card.isactive', 1);
$this->where('job_card.branch_id',$logged_user_branch_id);
$current_date = date('Y-m-d');
$this->where('DATE(job_card.created_at)', $current_date);
$this->groupBy('job_card.job_card_id');
$this->orderBy('job_card.job_card_id','DESC');
return $this->findAll();
}
public function today_delivery($logged_user_branch_id)
{
$this->select('job_card.*, vehicle.reg_no, vehicle.make, vehicle.colour, vehicle.model, make.make as bike_name, model.model_name as bike_modal_name');
$this->from('job_card');
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
$this->join('make', 'make.make_id = vehicle.make', 'left');
$this->join('model', 'model.model_id = vehicle.model', 'left');
$this->where('job_card.isactive', 1);
$this->where('job_card.branch_id',$logged_user_branch_id);
$current_date = date('Y-m-d');
$this->where('DATE(job_card.created_at)', $current_date);
$this->groupBy('job_card.job_card_id');
$this->orderBy('job_card.job_card_id','DESC');
return $this->findAll();
}
}