Platform::requests()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Statistics\Models;
6
7
use Illuminate\Database\Eloquent\Model;
8
use Rinvex\Cacheable\CacheableEloquent;
9
use Rinvex\Support\Traits\ValidatingTrait;
10
use Illuminate\Database\Eloquent\Relations\HasMany;
11
12
class Platform extends Model
13
{
14
    use ValidatingTrait;
15
    use CacheableEloquent;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $fillable = [
21
        'family',
22
        'version',
23
    ];
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    protected $casts = [
29
        'family' => 'string',
30
        'version' => 'string',
31
    ];
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public $timestamps = false;
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected $observables = [
42
        'validating',
43
        'validated',
44
    ];
45
46
    /**
47
     * The default rules that the model will validate against.
48
     *
49
     * @var array
50
     */
51
    protected $rules = [
52
        'family' => 'required|string',
53
        'version' => 'nullable|string',
54
    ];
55
56
    /**
57
     * Whether the model should throw a
58
     * ValidationException if it fails validation.
59
     *
60
     * @var bool
61
     */
62
    protected $throwValidationExceptions = true;
63
64
    /**
65
     * Create a new Eloquent model instance.
66
     *
67
     * @param array $attributes
68
     */
69
    public function __construct(array $attributes = [])
70
    {
71
        parent::__construct($attributes);
72
73
        $this->setTable(config('rinvex.statistics.tables.platforms'));
74
    }
75
76
    /**
77
     * The platform may have many requests.
78
     *
79
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
80
     */
81
    public function requests(): HasMany
82
    {
83
        return $this->hasMany(config('rinvex.statistics.models.request'), 'platform_id', 'id');
84
    }
85
}
86