Conditions | 7 |
Paths | 8 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
37 | public function scopeApproved($query, User $user = null) |
||
38 | { |
||
39 | $authedUser = auth('web')->user(); |
||
|
|||
40 | |||
41 | if ($user === null || $authedUser === null) { |
||
42 | $isOwner = false; |
||
43 | } |
||
44 | |||
45 | if ($authedUser && $authedUser->id === $user->id) { |
||
46 | $isOwner = true; |
||
47 | } |
||
48 | |||
49 | if (config('faithgen-sdk.source') || $isOwner) { |
||
50 | return $query; |
||
51 | } |
||
52 | |||
53 | return $query->whereApproved(true); |
||
54 | } |
||
55 | } |
||
56 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: