Total Complexity | 6 |
Total Lines | 65 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
20 | trait HasBannedAtHelpers |
||
21 | { |
||
22 | /** |
||
23 | * Set banned flag. |
||
24 | * |
||
25 | * @return $this |
||
26 | */ |
||
27 | public function setBannedFlag() |
||
28 | { |
||
29 | $this->setAttribute('banned_at', Carbon::now()); |
||
|
|||
30 | |||
31 | return $this; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Unset banned flag. |
||
36 | * |
||
37 | * @return $this |
||
38 | */ |
||
39 | public function unsetBannedFlag() |
||
40 | { |
||
41 | $this->setAttribute('banned_at', null); |
||
42 | |||
43 | return $this; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * If model is banned. |
||
48 | * |
||
49 | * @return bool |
||
50 | */ |
||
51 | public function isBanned(): bool |
||
52 | { |
||
53 | return $this->getAttributeValue('banned_at') !== null; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * If model is not banned. |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function isNotBanned(): bool |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Ban model. |
||
68 | * |
||
69 | * @param null|array $attributes |
||
70 | * @return \Cog\Contracts\Ban\Ban |
||
71 | */ |
||
72 | public function ban(array $attributes = []): BanContract |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Remove ban from model. |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public function unban(): void |
||
85 | } |
||
86 | } |
||
87 |