HasUserStamps::editor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Sqits\UserStamps\Concerns;
4
5
use Sqits\UserStamps\Observers\UserStampObserver;
6
7
trait HasUserStamps
8
{
9
    /**
10
     * Bootstrap the trait.
11
     *
12
     * @return void
13
     */
14
    public static function bootHasUserStamps()
15
    {
16
        static::observe(UserStampObserver::class);
17
    }
18
19
    /**
20
     * Get the user that created the model.
21
     *
22
     * @return Illuminate\Database\Eloquent\Relations\BelongsTo
0 ignored issues
show
Bug introduced by
The type Sqits\UserStamps\Concern...ent\Relations\BelongsTo was not found. Did you mean Illuminate\Database\Eloquent\Relations\BelongsTo? If so, make sure to prefix the type with \.
Loading history...
23
     */
24
    public function author()
25
    {
26
        return $this->belongsTo(
0 ignored issues
show
Bug introduced by
It seems like belongsTo() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        return $this->/** @scrutinizer ignore-call */ belongsTo(
Loading history...
27
            config('userstamps.users_model'),
28
            config('userstamps.created_by_column'),
29
            config('userstamps.users_table_column_id_name')
30
        );
31
    }
32
33
    /**
34
     * Get the user that edited the model.
35
     *
36
     * @return Illuminate\Database\Eloquent\Relations\BelongsTo
37
     */
38
    public function editor()
39
    {
40
        return $this->belongsTo(
41
            config('userstamps.users_model'),
42
            config('userstamps.updated_by_column'),
43
            config('userstamps.users_table_column_id_name')
44
        );
45
    }
46
47
    /**
48
     * Get the user that deleted the model.
49
     *
50
     * @return Illuminate\Database\Eloquent\Relations\BelongsTo
51
     */
52
    public function destroyer()
53
    {
54
        return $this->belongsTo(
55
            config('userstamps.users_model'),
56
            config('userstamps.deleted_by_column'),
57
            config('userstamps.users_table_column_id_name')
58
        );
59
    }
60
61
    /**
62
     * Has the model loaded the SoftDeletes trait.
63
     *
64
     * @return bool
65
     */
66
    public function usingSoftDeletes()
67
    {
68
        return $usingSoftDeletes = in_array(
0 ignored issues
show
Unused Code introduced by
The assignment to $usingSoftDeletes is dead and can be removed.
Loading history...
69
            'Illuminate\Database\Eloquent\SoftDeletes',
70
            class_uses_recursive(
71
                get_called_class()
72
            )
73
        );
74
    }
75
}
76