CanFilterByUser   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 2
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A scopeByCurrentUser() 0 3 1
1
<?php
2
3
namespace App\Traits;
4
5
use Illuminate\Database\Eloquent\Builder;
6
7
/**
8
 * Indicate that a (Model) object collection can be filtered by the current authenticated user.
9
 */
10
trait CanFilterByUser
11
{
12
    public function scopeByCurrentUser(Builder $query): Builder
13
    {
14
        return $query->where('user_id', auth()->user()->id);
15
    }
16
}
17