Completed
Push — master ( ea324c...2e8bb7 )
by Andrey
01:33
created

S3FileOptions::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 49

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
c 0
b 0
f 0
rs 9.1127
nc 1
cc 1
nop 0
1
<?php
2
3
namespace Itstructure\MFUploader\models;
4
5
/**
6
 * This is the model class for table "s3_file_options".
7
 *
8
 * @property int $mediafileId Mediafile id.
9
 * @property string $bucket Bucket.
10
 * @property string $prefix Prefix path.
11
 * @property Mediafile $mediafile
12
 *
13
 * @package Itstructure\MFUploader\models
14
 *
15
 * @author Andrey Girnik <[email protected]>
16
 */
17
class S3FileOptions extends \yii\db\ActiveRecord
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public static function tableName()
23
    {
24
        return 's3_file_options';
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function rules()
31
    {
32
        return [
33
            [
34
                [
35
                    'mediafileId',
36
                    'bucket',
37
                    'prefix',
38
                ],
39
                'required',
40
            ],
41
            [
42
                [
43
                    'mediafileId',
44
                ],
45
                'integer',
46
            ],
47
            [
48
                [
49
                    'bucket',
50
                ],
51
                'string',
52
                'max' => 64,
53
            ],
54
            [
55
                [
56
                    'prefix',
57
                ],
58
                'string',
59
                'max' => 128,
60
            ],
61
            [
62
                [
63
                    'mediafileId',
64
                ],
65
                'unique',
66
                'targetAttribute' => [
67
                    'mediafileId',
68
                ],
69
            ],
70
            [
71
                ['mediafileId'],
72
                'exist',
73
                'skipOnError' => true,
74
                'targetClass' => Mediafile::class,
75
                'targetAttribute' => ['mediafileId' => 'id'],
76
            ],
77
        ];
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function attributeLabels()
84
    {
85
        return [
86
            'mediafileId' => 'Mediafile ID',
87
            'bucket' => 'Bucket',
88
            'prefix' => 'Prefix',
89
        ];
90
    }
91
92
    /**
93
     * @return \yii\db\ActiveQuery
94
     */
95
    public function getMediaFile()
96
    {
97
        return $this->hasOne(Mediafile::class, ['id' => 'mediafileId']);
98
    }
99
}
100