Code Duplication    Length = 83-83 lines in 2 locations

src/Models/Statistics/Path.php 1 location

@@ 12-94 (lines=83) @@
9
use Muleta\Traits\Models\ValidatingTrait;
10
use Illuminate\Database\Eloquent\Relations\HasMany;
11
12
class Path extends Model
13
{
14
    use ValidatingTrait;
15
    use CacheableEloquent;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $fillable = [
21
        'host',
22
        'locale',
23
        'path',
24
        'method',
25
        'parameters',
26
    ];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected $casts = [
32
        'host' => 'string',
33
        'locale' => 'string',
34
        'path' => 'string',
35
        'method' => 'string',
36
        'parameters' => 'json',
37
    ];
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public $timestamps = false;
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected $observables = [
48
        'validating',
49
        'validated',
50
    ];
51
52
    /**
53
     * The default rules that the model will validate against.
54
     *
55
     * @var array
56
     */
57
    public $rules = [
58
        'host' => 'required|string',
59
        'locale' => 'required|string',
60
        'path' => 'required|string',
61
        'method' => 'required|string',
62
        'parameters' => 'nullable|array',
63
    ];
64
65
    /**
66
     * Whether the model should throw a
67
     * ValidationException if it fails validation.
68
     *
69
     * @var bool
70
     */
71
    protected $throwValidationExceptions = true;
72
73
    /**
74
     * Create a new Eloquent model instance.
75
     *
76
     * @param array $attributes
77
     */
78
    public function __construct(array $attributes = [])
79
    {
80
        parent::__construct($attributes);
81
82
        $this->setTable(\Illuminate\Support\Facades\Config::get('tracking.statistics.tables.paths'));
83
    }
84
85
    /**
86
     * The path may have many requests.
87
     *
88
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
89
     */
90
    public function requests(): HasMany
91
    {
92
        return $this->hasMany(\Illuminate\Support\Facades\Config::get('tracking.statistics.models.request'), 'path_id', 'id');
93
    }
94
}
95

src/Models/Statistics/Route.php 1 location

@@ 12-94 (lines=83) @@
9
use Muleta\Traits\Models\ValidatingTrait;
10
use Illuminate\Database\Eloquent\Relations\HasMany;
11
12
class Route extends Model
13
{
14
    use ValidatingTrait;
15
    use CacheableEloquent;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $fillable = [
21
        'name',
22
        'action',
23
        'middleware',
24
        'path',
25
        'parameters',
26
    ];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected $casts = [
32
        'name' => 'string',
33
        'action' => 'string',
34
        'middleware' => 'json',
35
        'path' => 'string',
36
        'parameters' => 'json',
37
    ];
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public $timestamps = false;
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected $observables = [
48
        'validating',
49
        'validated',
50
    ];
51
52
    /**
53
     * The default rules that the model will validate against.
54
     *
55
     * @var array
56
     */
57
    public $rules = [
58
        'name' => 'required|string',
59
        'action' => 'required|string',
60
        'middleware' => 'nullable|array',
61
        'path' => 'required|string',
62
        'parameters' => 'nullable|array',
63
    ];
64
65
    /**
66
     * Whether the model should throw a
67
     * ValidationException if it fails validation.
68
     *
69
     * @var bool
70
     */
71
    protected $throwValidationExceptions = true;
72
73
    /**
74
     * Create a new Eloquent model instance.
75
     *
76
     * @param array $attributes
77
     */
78
    public function __construct(array $attributes = [])
79
    {
80
        parent::__construct($attributes);
81
82
        $this->setTable(\Illuminate\Support\Facades\Config::get('tracking.statistics.tables.routes'));
83
    }
84
85
    /**
86
     * The route may have many requests.
87
     *
88
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
89
     */
90
    public function requests(): HasMany
91
    {
92
        return $this->hasMany(\Illuminate\Support\Facades\Config::get('tracking.statistics.models.request'), 'route_id', 'id');
93
    }
94
}
95