88 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Models;
 | |
| 
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| use Illuminate\Support\Facades\DB;
 | |
| 
 | |
| class DrvPhoneDevices extends Model
 | |
| {
 | |
| 	// t_phone_devices
 | |
| 	const IS_INACTIVE = 0;
 | |
| 	const IS_ACTIVE = 1;
 | |
|   
 | |
| 	const IS_LOGOUT = 0;
 | |
| 	const IS_LOGIN = 1;
 | |
| 
 | |
|     public static function get($filter = [])
 | |
|     {
 | |
|         $select = '';
 | |
|         $where = '';
 | |
|         $params = [];
 | |
| 
 | |
|         if (isset($filter['id'])) {
 | |
|             $where .= ' AND phn_drv.id = ?';
 | |
|             $params[] = $filter['id'];
 | |
|         }
 | |
|         if (isset($filter['device_id'])) {
 | |
|             $where .= ' AND phn_drv.device_id = ?';
 | |
|             $params[] = $filter['device_id'];
 | |
|         }
 | |
|         if (isset($filter['id'])) {
 | |
|             $where .= ' AND phn_drv.id = ?';
 | |
|             $params[] = $filter['id'];
 | |
|         }
 | |
| 		if (isset($filter['uid'])) {
 | |
|             $where .= ' AND phn_drv.uid = ?';
 | |
|             $params[] = $filter['uid'];
 | |
|         }
 | |
| 		if (isset($filter['drv_id'])) {
 | |
|             $where .= ' AND phn_drv.did = ?';
 | |
|             $params[] = $filter['drv_id'];
 | |
|         }
 | |
| 
 | |
| 		if (isset($filter['is_login'])) {
 | |
|             $where .= ' AND phn_drv.is_login = ?';
 | |
|             $params[] = $filter['is_login'];
 | |
|         }
 | |
| 		if (isset($filter['is_active'])) {
 | |
|             $where .= ' AND phn_drv.is_active = ?';
 | |
|             $params[] = $filter['is_active'];
 | |
|         }
 | |
| 
 | |
|         return DB::select("SELECT
 | |
| 		phn_drv.*
 | |
|         $select
 | |
|         FROM t_phone_devices as phn_drv
 | |
|         WHERE phn_drv.dlt is null
 | |
|         $where
 | |
|         ;", $params);
 | |
|     }
 | |
| 
 | |
|     public static function add($data)
 | |
|     {
 | |
|         $id = DB::table("t_phone_devices")->insertGetId($data);
 | |
|         return $id;
 | |
|     }
 | |
| 
 | |
|     public static function updt($id, $data)
 | |
|     {
 | |
|         return DB::table("t_phone_devices")->where("id", $id)->update($data);
 | |
|     }
 | |
| 
 | |
|     public static function updtByOrdDrvId($did, $data)
 | |
|     {
 | |
|         return DB::table("t_phone_devices")->where("did", $did)->update($data);
 | |
|     }
 | |
| 
 | |
|     public static function dlt($id)
 | |
|     {
 | |
|         return DB::table("t_phone_devices")->where("id", $id)->delete();
 | |
|     }
 | |
| 
 | |
|     public static function dltByOrdDrvId($did)
 | |
|     {
 | |
|         return DB::table("t_phone_devices")->where("did", $did)->delete();
 | |
|     }
 | |
| }
 | 
