|
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
|
|
|
/** |
|
15
|
|
|
* QueryTrait is trait class containing the database queries methods for the User model. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
|
18
|
|
|
* |
|
19
|
|
|
* @property static $this |
|
20
|
|
|
*/ |
|
21
|
|
|
trait UserScopes |
|
22
|
|
|
{ |
|
23
|
|
|
public function scopePrivate($query, $status = false) |
|
24
|
|
|
{ |
|
25
|
|
|
return $query->where('private', '=', $status); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function scopeDeveloperOrHigher($query) |
|
29
|
|
|
{ |
|
30
|
|
|
// return $query->where('role_id', '>', 1); |
|
31
|
|
|
|
|
32
|
|
|
return $query->where('users.role_id', '>', 1); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function scopeNotDeleted($query) |
|
36
|
|
|
{ |
|
37
|
|
|
return $query->where('deleted', '=', static::NOT_DELETED_USERS); |
|
38
|
|
|
|
|
39
|
|
|
return $query->where('users.deleted', '=', static::NOT_DELETED_USERS); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function scopeDeleted($query) |
|
43
|
|
|
{ |
|
44
|
|
|
return $query->where('deleted', '=', static::DELETED_USERS); |
|
45
|
|
|
|
|
46
|
|
|
return $query->where('users.deleted', '=', static::NOT_DELETED_USERS); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function scopeNotMemberOfProject($query, Project $project) |
|
50
|
|
|
{ |
|
51
|
|
|
if ($project->id > 0) { |
|
52
|
|
|
return $query->whereNotIn('id', $project->users(['user_id'])->dropdown('user_id')); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return $query; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return,dieorexitstatements that have been added for debug purposes.In the above example, the last
return falsewill never be executed, because a return statement has already been met in every possible execution path.