123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- namespace app\models\entity;
- class ProjectsLocotech extends \yii\db\ActiveRecord
- {
-
- public static function tableName()
- {
- return 'projects_locotech';
- }
-
- public function rules()
- {
- return [
- [['action', 'company', 'status', 'loco_number'], 'integer'],
- [['created'], 'safe'],
- [['loco_type', 'depo', 'depo_service'], 'string', 'max' => 255],
- ];
- }
-
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'action' => 'Action',
- 'company' => 'Company',
- 'status' => 'Status',
- 'loco_type' => 'Loco Type',
- 'loco_number' => 'Loco Number',
- 'depo' => 'Depo',
- 'depo_service' => 'Depo Service',
- 'created' => 'Created',
- 'tasks' => 'Tasks',
- 'actions_id' => 'Actions ID',
- ];
- }
- public function getTask()
- {
- return $this->hasMany(Tasks::class, ['input_id' => 'id']);
- }
- public function getProjecttypes()
- {
- return $this->hasOne(Projecttypes::class, ['id' => 'action']);
- }
- public function getSections()
- {
- return $this->hasOne(Sections::class, ['id' => 'section_id']);
- }
-
- public function getAcceptedTime()
- {
- $task = Tasks::find()
- ->select('min(accepted_time) as accepted_time')
- ->where(['input_id' => $this->id])
- ->one()
- ;
- return $task->accepted_time;
- }
-
- public function getFinishedTime()
- {
- if ($this->finished_time) return $this->finished_time;
- if ($this->status == 5) {
- $task = Tasks::find()
- ->select('max(finished_time) as finished_time')
- ->where(['input_id' => $this->id])
- ->one()
- ;
- return $task->finished_time;
- }
- return null;
- }
- }
|