InquiryForm.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
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace App\Models\Inquiry;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
/**
* Class InquiryForm
* @package App\Models\Inquiry
* @author zbj
* @date 2023/12/5
*/
class InquiryForm extends Base
{
use SoftDeletes;
//设置关联表名
/**
* @var mixed
*/
protected $connection = "custom_mysql";
protected $table = 'gl_inquiry_form';
/**
* 预设字段名称
* @author zbj
* @date 2023/12/5
*/
public static function fieldMap($field = ''){
$map = [
'name' => '姓名',
'email' => '邮箱',
'phone' => '电话',
'mobile' => '电话',
'message' => '询盘内容',
'company' => '公司名称'
];
if($field){
return $map[$field] ?? $field;
}
return $map;
}
public function getFieldAttribute($value)
{
return json_decode($value, true);
}
/**
* @author zbj
* @date 2023/12/5
*/
public static function getField($form_id){
$cache_key = 'inquiry_form_field_' . $form_id;
$field = Cache::get($cache_key);
if(!$field){
$field = self::where('id', $form_id)->value('field');
$field && Cache::set($cache_key, $field, 3600);
}
return $field;
}
}