Repository navigation
Expand file tree
/
Copy pathSystem.php
More file actions
executable file
·67 lines (54 loc) · 1.56 KB
/
Copy pathSystem.php
File metadata and controls
executable file
·67 lines (54 loc) · 1.56 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
56
57
58
59
60
61
62
63
64
65
66
67
<?php namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Auth, Input;
class System extends Model
{
const SYSTEM_INFO_TYPE = 1;
//
protected $table = 'systems';
public $timestamps = false;
protected $fillable = array(
'cate',
'system_name',
'system_value'
);
static $cate = [
self::SYSTEM_INFO_TYPE => '基本设置',
];
/**
* 获取指定配置值
* @param $field
* @return mixed
*/
public function getSystem($field)
{
return self::select('system_value')->where('system_name', $field)->pluck('system_value');
}
public static function getSystemSetting()
{
$result = array();
$settings = self::where('cate',1)->get();
foreach($settings as $item){
array_push($result,array("k" => $item->system_name,"v" => $item->system_value));
}
return $result;
}
public static function setSystemValue($key,$val){
$exist = self::select('system_value')->where('system_name', $key)->where("cate",System::SYSTEM_INFO_TYPE)->get();
if(!$exist->isEmpty()){
$data = array(
"id" > $exist[0]->id,
'cate' => System::SYSTEM_INFO_TYPE,
'system_value' => $val,
);
self::update($data);
}else{
$data = array(
'cate' => System::SYSTEM_INFO_TYPE,
'system_name' => $key,
'system_value' => $val,
);
self::create($data);
}
}
}