GeoConf.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/10/22
* Time: 17:01
*/
namespace App\Models\Geo;
use App\Models\Base;
use App\Models\Manage\ManageHr;
use Illuminate\Support\Facades\Cache;
/**
* GEO 相关配置
* Class GeoConf
* @package App\Models\Geo
*/
class GeoConf extends Base
{
/**
* @var string table
*/
protected $table = 'gl_project_geo_conf';
public function geoManage($name = '')
{
// 如果有搜索条件,直接查询(不缓存)
if (!empty($name)) {
$optimize = ManageHr::where(function($query) {
$query->where(['status' => ManageHr::STATUS_ONE, 'entry_position' => 46])
->orWhereIn('id', [11, 207, 875, 893]);
})->where('name', 'like', '%' . $name . '%')
->pluck('name', 'id')
->toArray();
ksort($optimize);
return $optimize;
}
// 没有搜索条件时使用缓存
$key = 'geo_manage_list_' . date('Ymd');
$optimize = Cache::get($key);
if (empty($optimize)) {
$optimize = ManageHr::where(function($query) {
$query->where(['status' => ManageHr::STATUS_ONE, 'entry_position' => 46])
->orWhereIn('id', [11, 207, 875, 893]);
})->pluck('name', 'id')->toArray();
ksort($optimize);
Cache::put($key, $optimize, 3600);
}
return $optimize;
}
}