Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#382)
by Cristian
03:31
created

Sluggable::scopeFindSimilarSlugs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 5
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\ModelTraits\SpatieTranslatable;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Builder;
7
8
trait Sluggable
9
{
10
    use \Cviebrock\EloquentSluggable\Sluggable;
11
12
    /**
13
     * Hook into the Eloquent model events to create or
14
     * update the slug as required.
15
     */
16
    public static function bootSluggable()
17
    {
18
        static::observe(app(SluggableObserver::class));
19
    }
20
21
    /**
22
     * Clone the model into a new, non-existing instance.
23
     *
24
     * @param  array|null $except
25
     * @return Model
26
     */
27
    public function replicate(array $except = null)
28
    {
29
        $instance = parent::replicate($except);
30
        (new SlugService())->slug($instance, true);
31
32
        return $instance;
33
    }
34
35
    /**
36
     * Query scope for finding "similar" slugs, used to determine uniqueness.
37
     *
38
     * @param \Illuminate\Database\Eloquent\Builder $query
39
     * @param \Illuminate\Database\Eloquent\Model $model
40
     * @param string $attribute
41
     * @param array $config
42
     * @param string $slug
43
     * @return \Illuminate\Database\Eloquent\Builder
44
     */
45
    public function scopeFindSimilarSlugs(Builder $query, Model $model, $attribute, $config, $slug)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
    {
47
        $separator = $config['separator'];
48
        $attribute = $attribute.'->'.$this->getLocale();
49
50
        return $query->where(function (Builder $q) use ($attribute, $slug, $separator) {
51
            $q->where($attribute, '=', $slug)
52
                ->orWhere($attribute, 'LIKE', $slug.$separator.'%');
53
        });
54
    }
55
}
56