Issues (107)

src/App/Models/Activity.php (6 issues)

1
<?php
2
3
namespace jeremykenedy\LaravelLogger\App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
The type Illuminate\Database\Eloquent\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Database\Eloquent\SoftDeletes;
0 ignored issues
show
The type Illuminate\Database\Eloquent\SoftDeletes was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class Activity extends Model
9
{
10
    use SoftDeletes;
11
12
    /**
13
     * The table associated with the model.
14
     *
15
     * @var string
16
     */
17
    protected $table;
18
19
    /**
20
     * The connection name for the model.
21
     *
22
     * @var string
23
     */
24
    protected $connection;
25
26
    /**
27
     * Indicates if the model should be timestamped.
28
     *
29
     * @var bool
30
     */
31
    public $timestamps = true;
32
33
    /**
34
     * The attributes that are not mass assignable.
35
     *
36
     * @var array
37
     */
38
    protected $guarded = [
39
        'id',
40
    ];
41
42
    /**
43
     * The attributes that should be mutated to dates.
44
     *
45
     * @var array
46
     */
47
    protected $dates = [
48
        'created_at',
49
        'updated_at',
50
        'deleted_at',
51
    ];
52
53
    /**
54
     * Fillable fields for a Profile.
55
     *
56
     * @var array
57
     */
58
    protected $fillable = [
59
        'description',
60
        'userType',
61
        'userId',
62
        'route',
63
        'ipAddress',
64
        'userAgent',
65
        'locale',
66
        'referer',
67
        'methodType',
68
    ];
69
70
    protected $casts = [
71
        'description'   => 'string',
72
        'user'          => 'integer',
73
        'route'         => 'string',
74
        'ipAddress'     => 'string',
75
        'userAgent'     => 'string',
76
        'locale'        => 'string',
77
        'referer'       => 'string',
78
        'methodType'    => 'string',
79
    ];
80
81
    /**
82
     * Create a new instance to set the table and connection.
83
     *
84
     * @return void
85
     */
86
    public function __construct($attributes = [])
87
    {
88
        parent::__construct($attributes);
89
        $this->table = config('LaravelLogger.loggerDatabaseTable');
0 ignored issues
show
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

89
        $this->table = /** @scrutinizer ignore-call */ config('LaravelLogger.loggerDatabaseTable');
Loading history...
90
        $this->connection = config('LaravelLogger.loggerDatabaseConnection');
91
    }
92
93
    /**
94
     * Get the database connection.
95
     */
96
    public function getConnectionName()
97
    {
98
        return $this->connection;
99
    }
100
101
    /**
102
     * Get the database connection.
103
     */
104
    public function getTableName()
105
    {
106
        return $this->table;
107
    }
108
109
    /**
110
     * An activity has a user.
111
     *
112
     * @var array
113
     */
114
    public function user()
115
    {
116
        return $this->hasOne(config('LaravelLogger.defaultUserModel'));
0 ignored issues
show
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

116
        return $this->hasOne(/** @scrutinizer ignore-call */ config('LaravelLogger.defaultUserModel'));
Loading history...
117
    }
118
119
    /**
120
     * Get a validator for an incoming Request.
121
     *
122
     * @param array $merge (rules to optionally merge)
123
     *
124
     * @return array
125
     */
126
    public static function rules($merge = [])
127
    {
128
        if (\Illuminate\Foundation\Application::VERSION < 5.8) {
0 ignored issues
show
The type Illuminate\Foundation\Application was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
129
            $route_url_check = 'active_url';
130
        } else {
131
            $route_url_check = 'url';
132
        }
133
134
        return array_merge(
135
            [
136
                'description'   => 'required|string',
137
                'userType'      => 'required|string',
138
                'userId'        => 'nullable|integer',
139
                'route'         => 'nullable|'.$route_url_check,
140
                'ipAddress'     => 'nullable|ip',
141
                'userAgent'     => 'nullable|string',
142
                'locale'        => 'nullable|string',
143
                'referer'       => 'nullable|string',
144
                'methodType'    => 'nullable|string',
145
            ],
146
            $merge
147
        );
148
    }
149
150
    /**
151
     * User Agent Parsing Helper.
152
     *
153
     * @return string
154
     */
155
    public function getUserAgentDetailsAttribute()
156
    {
157
        return \jeremykenedy\LaravelLogger\App\Http\Traits\UserAgentDetails::details($this->userAgent);
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 103 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
158
    }
159
}
160