Varchar   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Attributes\Models\Type;
6
7
use Rinvex\Attributes\Models\Value;
8
9
/**
10
 * Rinvex\Attributes\Models\Type\Varchar.
11
 *
12
 * @property int                                                $id
13
 * @property string                                             $content
14
 * @property int                                                $attribute_id
15
 * @property int                                                $entity_id
16
 * @property string                                             $entity_type
17
 * @property \Carbon\Carbon|null                                $created_at
18
 * @property \Carbon\Carbon|null                                $updated_at
19
 * @property-read \Rinvex\Attributes\Models\Attribute           $attribute
20
 * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $entity
21
 *
22
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereAttributeId($value)
23
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereContent($value)
24
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereCreatedAt($value)
25
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereEntityId($value)
26
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereEntityType($value)
27
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereId($value)
28
 * @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Varchar whereUpdatedAt($value)
29
 * @mixin \Eloquent
30
 */
31
class Varchar extends Value
32
{
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected $casts = [
37
        'content' => 'string',
38
        'attribute_id' => 'integer',
39
        'entity_id' => 'integer',
40
        'entity_type' => 'string',
41
    ];
42
43
    /**
44
     * Create a new Eloquent model instance.
45
     *
46
     * @param array $attributes
47
     */
48
    public function __construct(array $attributes = [])
49
    {
50
        parent::__construct($attributes);
51
52
        $this->setTable(config('rinvex.attributes.tables.attribute_varchar_values'));
53
        $this->setRules([
54
            'content' => 'required|string|max:150',
55
            'attribute_id' => 'required|integer|exists:'.config('rinvex.attributes.tables.attributes').',id',
56
            'entity_id' => 'required|integer',
57
            'entity_type' => 'required|string',
58
        ]);
59
    }
60
}
61