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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A bootSluggable() 0 4 1
A replicate() 0 7 1
A scopeFindSimilarSlugs() 0 10 1
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