Passed
Push — master ( 4b8ed9...7ee2bd )
by Alexey
05:58
created

Review::relations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace Ecommerce\Item;
10
11
/**
12
 * Description of Review
13
 *
14
 * @author benzu
15
 */
16
class Review extends \Model {
17
18
    public static $cols = [
19
        'item_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'item'],
20
        'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
21
        'name' => ['type' => 'text'],
22
        'mail' => ['type' => 'email'],
23
        'text' => ['type' => 'textarea'],
24
        'rating' => ['type' => 'number'],
25
        'file_id' => ['type' => 'file'],
26
        'status' => ['type' => 'select', 'source' => 'array', 'default' => 'new', 'sourceArray' => [
27
                'new' => 'Новый',
28
                'accept' => 'Принят',
29
                'denied' => 'Недопущен'
30
            ]
31
        ],
32
        'voteup' => ['type' => 'number'],
33
        'votedown' => ['type' => 'number'],
34
        'date_create' => ['type' => 'dateTime']
35
    ];
36
    public static $labels = [
37
        'item_id' => 'Товар',
38
        'user_id' => 'Пользователь',
39
        'name' => 'Имя',
40
        'mail' => 'Email',
41
        'text' => 'Текст отзыва',
42
        'rating' => 'Оценка',
43
        'file_id' => 'Вложение',
44
        'status' => 'Статус модерации',
45
        'date_create' => 'Дата'
46
    ];
47
    public static $dataManagers = [
48
        'manager' => [
49
            'cols' => ['name', 'item_id', 'status', 'mail', 'user_id', 'rating', 'date_create']
50
        ]
51
    ];
52
    public static $forms = [
53
        'manager' => [
54
            'map' => [
55
                ['name', 'mail'],
56
                ['text'],
57
                ['rating', 'status'],
58
                ['voteup', 'votedown']
59
            ]
60
        ]
61
    ];
62
63
    public static function relations() {
64
        return [
65
            'user' => [
66
                'col' => 'user_id',
67
                'model' => 'Users\User'
68
            ],
69
            'item' => [
70
                'col' => 'item_id',
71
                'model' => 'Ecommerce\Item'
72
            ],
73
        ];
74
    }
75
}