|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Model\MailJob; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
6
|
|
|
|
|
7
|
|
|
class Condition extends Model |
|
8
|
|
|
{ |
|
9
|
|
|
protected $table = 'conditions'; |
|
10
|
|
|
protected $fillable = ['job', 'value']; |
|
11
|
|
|
|
|
12
|
|
|
public function getConditionValue($job) |
|
13
|
|
|
{ |
|
14
|
|
|
$value = ['condition' => '', 'at' => '']; |
|
15
|
|
|
$condition = $this->where('job', $job)->first(); |
|
|
|
|
|
|
16
|
|
|
if ($condition) { |
|
17
|
|
|
$condition_value = explode(',', $condition->value); |
|
18
|
|
|
$value = ['condition' => $condition_value, 'at' => '']; |
|
19
|
|
|
if (is_array($condition_value)) { |
|
20
|
|
|
$value = ['condition' => $this->checkArray(0, $condition_value), 'at' => $this->checkArray(1, $condition_value)]; |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
return $value; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
View Code Duplication |
public function checkArray($key, $array) |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
$value = ''; |
|
30
|
|
|
if (is_array($array)) { |
|
31
|
|
|
if (array_key_exists($key, $array)) { |
|
32
|
|
|
$value = $array[$key]; |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $value; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function checkActiveJob() |
|
40
|
|
|
{ |
|
41
|
|
|
$result = ['fetching' => '', 'notification' => '', 'work' => '', 'message' => '', 'remind' => '']; |
|
42
|
|
|
$emails = new \App\Model\helpdesk\Settings\Email(); |
|
43
|
|
|
$email = $emails->find(1); |
|
|
|
|
|
|
44
|
|
|
if ($email) { |
|
45
|
|
|
if ($email->email_fetching == 1) { |
|
46
|
|
|
$result['fetching'] = true; |
|
47
|
|
|
} |
|
48
|
|
|
if ($email->notification_cron == 1) { |
|
49
|
|
|
$result['notification'] = true; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
$works = new \App\Model\helpdesk\Workflow\WorkflowClose(); |
|
53
|
|
|
$work = $works->find(1); |
|
|
|
|
|
|
54
|
|
|
//dd($work); |
|
55
|
|
|
if ($work) { |
|
56
|
|
|
if ($work->condition == 1) { |
|
57
|
|
|
$result['work'] = true; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $result; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: