1 | <?php |
||||||
2 | |||||||
3 | /* |
||||||
4 | * This file is part of Laravel Eloquent Flag. |
||||||
5 | * |
||||||
6 | * (c) Anton Komarev <[email protected]> |
||||||
7 | * |
||||||
8 | * For the full copyright and license information, please view the LICENSE |
||||||
9 | * file that was distributed with this source code. |
||||||
10 | */ |
||||||
11 | |||||||
12 | declare(strict_types=1); |
||||||
13 | |||||||
14 | namespace Cog\Flag\Traits\Classic; |
||||||
15 | |||||||
16 | use Illuminate\Support\Facades\Date; |
||||||
17 | |||||||
18 | trait HasApprovedAtHelpers |
||||||
19 | { |
||||||
20 | public function initializeHasApprovedAtHelpers(): void |
||||||
21 | { |
||||||
22 | $this->casts['approved_at'] = 'datetime'; |
||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||||
23 | } |
||||||
24 | |||||||
25 | public function isApproved(): bool |
||||||
26 | { |
||||||
27 | return !is_null($this->getAttributeValue('approved_at')); |
||||||
0 ignored issues
–
show
It seems like
getAttributeValue() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
28 | } |
||||||
29 | |||||||
30 | public function isNotApproved(): bool |
||||||
31 | { |
||||||
32 | return !$this->isApproved(); |
||||||
33 | } |
||||||
34 | |||||||
35 | public function approve(): void |
||||||
36 | { |
||||||
37 | $this->setAttribute('approved_at', Date::now()); |
||||||
0 ignored issues
–
show
It seems like
setAttribute() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
38 | $this->save(); |
||||||
0 ignored issues
–
show
It seems like
save() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
39 | |||||||
40 | $this->fireModelEvent('approved', false); |
||||||
0 ignored issues
–
show
It seems like
fireModelEvent() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
41 | } |
||||||
42 | |||||||
43 | public function undoApprove(): void |
||||||
44 | { |
||||||
45 | $this->setAttribute('approved_at', null); |
||||||
46 | $this->save(); |
||||||
47 | |||||||
48 | $this->fireModelEvent('approvedUndone', false); |
||||||
49 | } |
||||||
50 | } |
||||||
51 |