Passed
Push — master ( 09f39f...15b7a9 )
by Stephen
03:33 queued 01:24
created

IdOrderScope   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 4 1
1
<?php
2
3
namespace Sfneal\Scopes;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Scope;
8
9
class IdOrderScope implements Scope
10
{
11
    /**
12
     * Apply the scope to a given Eloquent query builder.
13
     *
14
     * @param  Builder  $builder
15
     * @param  Model  $model
16
     * @return void
17
     */
18
    public function apply(Builder $builder, Model $model)
19
    {
20
        // Order returned collection by project_id (largest to smallest)
21
        $builder->orderBy($model->getKeyName(), 'desc');
22
    }
23
}
24