1 <?php
2
3 namespace Docoflow\Models;
4
5 use CDbCriteria;
6 use CActiveRecord;
7 use CActiveDataProvider;
8 use Docoflow\Traits\HasMutator;
9
10 /**
11 * This is the model class for table "workflow_groups".
12 *
13 * The followings are the available columns in table 'workflow_groups':
14 *
15 * @property integer $id
16 * @property integer $workflow_step_id
17 * @property string $name
18 * @property integer $status
19 *
20 * @author Krisan Alfa Timur <krisanalfa@docotel.co.id>
21 */
22 class WorkflowGroups extends CActiveRecord
23 {
24 use HasMutator;
25
26 /**
27 * Returns the static model of the specified AR class.
28 *
29 * @param string $className active record class name.
30 *
31 * @return WorkflowGroups the static model class
32 */
33 public static function model($className = __CLASS__)
34 {
35 return parent::model($className);
36 }
37
38 /**
39 * @return CDbConnection database connection
40 */
41 public function getDbConnection()
42 {
43 return container('docoflow.connection');
44 }
45
46 /**
47 * @return string the associated database table name
48 */
49 public function tableName()
50 {
51 return 'workflow_groups';
52 }
53
54 /**
55 * @return array validation rules for model attributes.
56 */
57 public function rules()
58 {
59 // NOTE: you should only define rules for those attributes that
60 // will receive user inputs.
61 return array(
62 array('workflow_step_id', 'required'),
63 array('workflow_step_id, status', 'numerical', 'integerOnly' => true),
64 array('name', 'length', 'max' => 255),
65 // The following rule is used by search().
66 // Please remove those attributes that should not be searched.
67 array('id, workflow_step_id, name, status', 'safe', 'on' => 'search'),
68 );
69 }
70
71 /**
72 * @return array relational rules.
73 */
74 public function relations()
75 {
76 // NOTE: you may need to adjust the relation name and the related
77 // class name for the relations automatically generated below.
78 return array(
79 'step' => array(static::BELONGS_TO, '\Docoflow\Models\WorkflowStep', 'workflow_step_id'),
80 'verificators' => array(static::HAS_MANY, '\Docoflow\Models\WorkflowVerificator', 'workflow_groups_id'),
81 );
82 }
83
84 /**
85 * @return array customized attribute labels (name=>label)
86 */
87 public function attributeLabels()
88 {
89 return array(
90 'id' => 'ID',
91 'workflow_step_id' => 'Workflow Step',
92 'name' => 'Name',
93 'status' => 'Status',
94 );
95 }
96
97 /**
98 * Retrieves a list of models based on the current search/filter conditions.
99 *
100 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
101 */
102 public function search()
103 {
104 // Warning: Please modify the following code to remove attributes that
105 // should not be searched.
106
107 $criteria = new CDbCriteria();
108
109 $criteria->compare('id', $this->id);
110 $criteria->compare('workflow_step_id', $this->workflow_step_id);
111 $criteria->compare('name', $this->name, true);
112 $criteria->compare('status', $this->status);
113
114 return new CActiveDataProvider($this, array(
115 'criteria' => $criteria,
116 ));
117 }
118 }
119