Log   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 73
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Models;
6
7
use Watson\Validating\ValidatingTrait;
8
use Rinvex\Cacheable\CacheableEloquent;
9
use Spatie\Activitylog\Models\Activity;
10
11
/**
12
 * Cortex\Foundation\Models\Log.
13
 *
14
 * @property int                                                                         $id
15
 * @property string                                                                      $log_name
16
 * @property string                                                                      $description
17
 * @property int|null                                                                    $subject_id
18
 * @property string|null                                                                 $subject_type
19
 * @property int|null                                                                    $causer_id
20
 * @property string|null                                                                 $causer_type
21
 * @property \Illuminate\Support\Collection                                              $properties
22
 * @property \Carbon\Carbon                                                              $created_at
23
 * @property \Carbon\Carbon                                                              $updated_at
24
 * @property-read \Cortex\Auth\Models\User|\Illuminate\Database\Eloquent\Model|\Eloquent $causer
25
 * @property-read mixed                                                                  $changes
26
 * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent                          $subject
27
 *
28
 * @method static \Illuminate\Database\Eloquent\Builder|\Spatie\Activitylog\Models\Activity causedBy(\Illuminate\Database\Eloquent\Model $causer)
29
 * @method static \Illuminate\Database\Eloquent\Builder|\Spatie\Activitylog\Models\Activity forSubject(\Illuminate\Database\Eloquent\Model $subject)
30
 * @method static \Illuminate\Database\Eloquent\Builder|\Spatie\Activitylog\Models\Activity inLog($logNames)
31
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereCauserId($value)
32
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereCauserType($value)
33
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereCreatedAt($value)
34
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereDescription($value)
35
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereId($value)
36
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereLogName($value)
37
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereProperties($value)
38
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereSubjectId($value)
39
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereSubjectType($value)
40
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Foundation\Models\Log whereUpdatedAt($value)
41
 * @mixin \Eloquent
42
 */
43
class Log extends Activity
44
{
45
    use ValidatingTrait;
46
    use CacheableEloquent;
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    protected $fillable = [
52
        'log_name',
53
        'description',
54
        'subject_id',
55
        'subject_type',
56
        'causer_id',
57
        'causer_type',
58
        'properties',
59
    ];
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    protected $casts = [
65
        'properties' => 'collection',
66
        'log_name' => 'string',
67
        'description' => 'string',
68
        'subject_id' => 'integer',
69
        'subject_type' => 'string',
70
        'causer_id' => 'integer',
71
        'causer_type' => 'string',
72
    ];
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    protected $observables = [
78
        'validating',
79
        'validated',
80
    ];
81
82
    /**
83
     * The default rules that the model will validate against.
84
     *
85
     * @var array
86
     */
87
    protected $rules = [
88
        'log_name' => 'required|string|max:150',
89
        'description' => 'nullable|string|max:10000',
90
        'subject_id' => 'nullable|integer',
91
        'subject_type' => 'nullable|string|max:150',
92
        'causer_id' => 'nullable|integer',
93
        'causer_type' => 'nullable|string|max:150',
94
    ];
95
96
    /**
97
     * Whether the model should throw a
98
     * ValidationException if it fails validation.
99
     *
100
     * @var bool
101
     */
102
    protected $throwValidationExceptions = true;
103
104
    /**
105
     * Create a new Log model instance.
106
     *
107
     * @param array $attributes
108
     */
109
    public function __construct(array $attributes = [])
110
    {
111
        parent::__construct($attributes);
112
113
        $this->setTable(config('cortex.foundation.tables.activity_log'));
114
    }
115
}
116