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\Text. |
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\Text whereAttributeId($value) |
23
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Text whereContent($value) |
24
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Text whereCreatedAt($value) |
25
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Text whereEntityId($value) |
26
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Text whereEntityType($value) |
27
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Text whereId($value) |
28
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Text whereUpdatedAt($value) |
29
|
|
|
* @mixin \Eloquent |
30
|
|
|
*/ |
31
|
|
|
class Text 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_text_values')); |
53
|
|
|
$this->setRules([ |
54
|
|
|
'content' => 'required|string|max:10000', |
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
|
|
|
|