1 <?php
2
3 namespace Docoflow\Models;
4
5 use Yii;
6 use CDbCriteria;
7 use CActiveRecord;
8 use CActiveDataProvider;
9
10 /**
11 * This is the model class for table "workflow_action".
12 *
13 * The followings are the available columns in table 'workflow_action':
14 *
15 * @property int $id
16 * @property int $from_state_activity_id
17 * @property int $to_state_activity_id
18 */
19 class WorkflowAction extends CActiveRecord
20 {
21 /**
22 * Returns the static model of the specified AR class.
23 *
24 * @param string $className active record class name.
25 *
26 * @return WorkflowAction the static model class
27 */
28 public static function model($className = __CLASS__)
29 {
30 return parent::model($className);
31 }
32
33 /**
34 * Get DB Connection
35 *
36 * @return \CDbConnection
37 */
38 public function getDbConnection()
39 {
40 Yii::app()->container->bindIf('docoflow.connection', function ($container) {
41 return Yii::app()->db;
42 });
43
44 return Yii::app()->container->make('docoflow.connection');
45 }
46
47 /**
48 * @return string the associated database table name
49 */
50 public function tableName()
51 {
52 return '"workflow_action"';
53 }
54
55 /**
56 * @return array validation rules for model attributes.
57 */
58 public function rules()
59 {
60 // NOTE: you should only define rules for those attributes that
61 // will receive user inputs.
62 return array(
63 array('from_state_activity_id, to_state_activity_id', 'required'),
64 array('from_state_activity_id, to_state_activity_id', 'numerical', 'integerOnly' => true),
65 // The following rule is used by search().
66 // Please remove those attributes that should not be searched.
67 array('id, from_state_activity_id, to_state_activity_id', '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 'fromStateActivity' => [static::BELONGS_TO, WorkflowStateActivity::class, 'from_state_activity_id'],
80 'toStateActivity' => [static::BELONGS_TO, WorkflowStateActivity::class, 'to_state_activity_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 'from_state_activity_id' => 'From State Activity',
92 'to_state_activity_id' => 'To State Activity',
93 );
94 }
95
96 /**
97 * Retrieves a list of models based on the current search/filter conditions.
98 *
99 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
100 */
101 public function search()
102 {
103 // Warning: Please modify the following code to remove attributes that
104 // should not be searched.
105
106 $criteria = new CDbCriteria();
107
108 $criteria->compare('"id"', $this->id);
109 $criteria->compare('"from_state_activity_id"', $this->from_state_activity_id);
110 $criteria->compare('"to_state_activity_id"', $this->to_state_activity_id);
111
112 return new CActiveDataProvider($this, array(
113 'criteria' => $criteria,
114 ));
115 }
116 }
117