Completed
Push — master ( 19e1c8...a74d0d )
by Christopher
01:06
created

CommentScopes::scopeUnapproved()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Chriscreates\Blog\Traits\Comment;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Builder;
7
8
trait CommentScopes
9
{
10
    public function scopeLatest(Builder $query)
11
    {
12
        return $query->orderBy('created_at', 'DESC');
0 ignored issues
show
Bug introduced by
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
13
    }
14
15
    public function scopeLastMonth(Builder $query)
16
    {
17
        return $query->whereBetween('created_at', [
18
            Carbon::now()->subMonth(), Carbon::now(),
19
        ])->latest();
20
    }
21
22
    public function scopeLastWeek(Builder $query)
23
    {
24
        return $query->whereBetween('created_at', [
25
            Carbon::now()->subWeek(), Carbon::now(),
26
        ])->latest();
27
    }
28
29
    public function scopeApproved($query)
30
    {
31
        return $query->where('is_approved', true);
32
    }
33
34
    public function scopeUnapproved($query)
35
    {
36
        return $query->where('is_approved', false);
37
    }
38
}
39