1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Tinyissue package. |
5
|
|
|
* |
6
|
|
|
* (c) Mohamed Alsharaf <[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
|
|
|
namespace Tinyissue\Model; |
13
|
|
|
|
14
|
|
|
use Illuminate\Database\Eloquent\Builder; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* UserScopes is trait class containing the model scope methods. |
18
|
|
|
* |
19
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
20
|
|
|
* |
21
|
|
|
* @property static $this |
22
|
|
|
*/ |
23
|
|
|
trait UserScopes |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Get user by private status. |
27
|
|
|
* |
28
|
|
|
* @param Builder $query |
29
|
|
|
* @param bool $status |
30
|
|
|
* |
31
|
|
|
* @return Builder |
32
|
|
|
*/ |
33
|
|
|
public function scopePrivate(Builder $query, $status = false) |
34
|
|
|
{ |
35
|
|
|
return $query->where('private', '=', $status); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get user that are not private status. |
40
|
|
|
* |
41
|
|
|
* @param Builder $query |
42
|
|
|
* |
43
|
|
|
* @return Builder |
44
|
|
|
*/ |
45
|
|
|
public function scopeNotPrivate(Builder $query) |
46
|
|
|
{ |
47
|
|
|
return $query->where('private', '=', false); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get user with role developer or manager or admin. |
52
|
|
|
* |
53
|
|
|
* @param Builder $query |
54
|
|
|
* |
55
|
|
|
* @return Builder |
56
|
|
|
*/ |
57
|
|
|
public function scopeDeveloperOrHigher(Builder $query) |
58
|
|
|
{ |
59
|
|
|
return $query->where('users.role_id', '>', 1); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Not deleted user. |
64
|
|
|
* |
65
|
|
|
* @param Builder $query |
66
|
|
|
* |
67
|
|
|
* @return Builder |
68
|
|
|
*/ |
69
|
|
|
public function scopeActive(Builder $query) |
70
|
|
|
{ |
71
|
|
|
return $query->where('deleted', '=', static::NOT_DELETED_USERS); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Deleted user. |
76
|
|
|
* |
77
|
|
|
* @param Builder $query |
78
|
|
|
* |
79
|
|
|
* @return Builder |
80
|
|
|
*/ |
81
|
|
|
public function scopeRemoved(Builder $query) |
82
|
|
|
{ |
83
|
|
|
return $query->where('deleted', '=', static::DELETED_USERS); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get users that are not member of a project. |
88
|
|
|
* |
89
|
|
|
* @param Builder $query |
90
|
|
|
* @param Project $project |
91
|
|
|
* |
92
|
|
|
* @return Builder |
93
|
|
|
*/ |
94
|
|
|
public function scopeNotMemberOfProject(Builder $query, Project $project) |
95
|
|
|
{ |
96
|
|
|
if ($project->id > 0) { |
97
|
|
|
return $query->whereNotIn('id', $project->users(['user_id'])->dropdown('user_id')); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
return $query; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.