1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
8
|
|
|
* @link https://vistart.name/ |
9
|
|
|
* @copyright Copyright (c) 2016 vistart |
10
|
|
|
* @license https://vistart.name/license/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace vistart\Models\traits; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* This trait is used for building notification model. |
17
|
|
|
* |
18
|
|
|
* @version 2.0 |
19
|
|
|
* @author vistart <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
trait NotificationTrait |
22
|
|
|
{ |
23
|
|
|
use NotificationRangeTrait; |
24
|
|
|
|
25
|
|
|
public $linkAttrbute = false; |
26
|
|
|
|
27
|
|
|
public function getLink() |
28
|
|
|
{ |
29
|
|
|
$linkAttribute = $this->linkAttrbute; |
30
|
|
|
return $this->$linkAttribute; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function setLink($link) |
34
|
|
|
{ |
35
|
|
|
$linkAttribute = $this->linkAttrbute; |
36
|
|
|
return $this->$linkAttribute = $link; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getNotificationRules() |
40
|
|
|
{ |
41
|
|
|
$rules = $this->getNotificationRangeRules(); |
42
|
|
|
|
43
|
|
|
if (is_string($this->linkAttrbute)) { |
44
|
|
|
$rules[] = [ |
45
|
|
|
$this->linkAttrbute, 'string', |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
return $rules; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function enabledFields() |
52
|
|
|
{ |
53
|
|
|
$fields = parent::enabledFields(); |
54
|
|
|
if (is_string($this->linkAttribute)) { |
|
|
|
|
55
|
|
|
$fields[] = $this->linkAttrbute; |
56
|
|
|
} |
57
|
|
|
if (is_string($this->rangeAttribute)) { |
58
|
|
|
$fields[] = $this->rangeAttribute; |
59
|
|
|
} |
60
|
|
|
return $fields; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function rules() |
64
|
|
|
{ |
65
|
|
|
return array_merge(parent::rules(), $this->getNotificationRules()); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.