You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
simple-yewu/common/models/Car2T.php

206 lines
5.8 KiB

<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "car2_t".
*
* @property integer $id
* @property integer $user_id
* @property integer $car_type_id
* @property integer $car_use_id
* @property string $car_no
* @property string $factory_model
* @property string $car_model
* @property string $register_date
* @property string $insurer1_date
* @property string $insurer2_date
* @property string $id_man
* @property string $id_number
* @property string $engine_no
* @property string $car_frame_no
* @property integer $brand_id
* @property integer $series_id
* @property integer $displacement_id
* @property string $car_year
* @property integer $seats
* @property string $car_man
* @property string $phone
* @property string $remark
* @property integer $location
* @property integer $invalid_flag
* @property integer $invalid_id
* @property string $print_date
* @property string $car_man_number
* @property integer $is_track
* @property integer $times
* @property string $old_user
* @property string $company
* @property string $created_at
* @property string $updated_at
*/
class Car2T extends \common\models\Base
{
public static function getDb()
{
// use the "db2" application component
return \Yii::$app->db3;
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'car_t';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'car_type_id', 'car_use_id'], 'required'],
[['user_id', 'car_type_id', 'car_use_id','seats','brand_id','series_id','displacement_id','location','invalid_id','invalid_flag','is_track','times'], 'integer'],
[['register_date', 'insurer1_date', 'insurer2_date','id_man','id_number','print_date','car_man_number', 'created_at', 'updated_at'], 'safe'],
[['car_no', 'factory_model', 'car_model', 'engine_no', 'car_frame_no','old_user'], 'string', 'max' => 50],
[['car_year'], 'string', 'max' => 10],
[['car_man','phone','remark','company'], 'string', 'max' => 200],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'car_type_id' => 'Car Type ID',
'car_use_id' => 'Car Use ID',
'car_no' => 'Car No',
'factory_model' => 'Factory Model',
'car_model' => 'Car Model',
'register_date' => 'Register Date',
'insurer1_date' => 'Insurer 1 Date',
'insurer2_date' => 'Insurer 2 Date',
'id_man' => 'ID Man',
'id_number' => 'ID Number',
'engine_no' => 'Engine No',
'car_frame_no' => 'Car Frame No',
'brand_id' => 'Brand ID',
'series_id' => 'Series ID',
'displacement_id' => 'Displacement ID',
'car_year' => 'Car Year',
'seats' => 'Seats',
'car_man' => 'Car Man',
'phone' => 'Phone',
'remark' => 'Remark',
'location' => 'Location',
'invalid_flag' => 'Invalid Flag',
'invalid_id' => 'Invalid ID',
'print_date' => 'Print Date',
'car_man_number' => 'Car Man Number',
'is_track' => 'Is Track',
'times' => 'Times',
'old_user' => 'Old User',
'company' => 'Company',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
public function getUser()
{
return $this->hasOne(UserT::className(),['id'=>'user_id']);
}
public function getCarType()
{
return $this->hasOne(CarTypeT::className(),['id'=>'car_type_id']);
}
public function getCarUse()
{
return $this->hasOne(CarUseT::className(),['id'=>'car_use_id']);
}
public function getAppointment()
{
return $this->hasOne(AppointmentT::className(),['car_id'=>'id']);
}
public function getAppointments()
{
return $this->hasMany(AppointmentHistoryT::className(),['car_id'=>'id']);
}
public function getOrders()
{
return $this->hasMany(OrderT::className(),['car_id'=>'id']);
}
public function getBrand()
{
return $this->hasOne(BrandT::className(),['id'=>'brand_id']);
}
public function getInvalid()
{
return $this->hasOne(InvalidT::className(),['id'=>'invalid_id']);
}
public function getSeries()
{
return $this->hasOne(SeriesT::className(),['id'=>'series_id']);
}
public function getDisplacement()
{
return $this->hasOne(DisplacementT::className(),['id'=>'displacement_id']);
}
public function getLocation()
{
$name = '';
switch($this->location) {
case 1:
$name = 'A库';
break;
case 2:
$name = 'B库';
break;
case 3:
$name = 'C库';
break;
case 4:
$name = 'D库';
break;
case 5:
$name = '无效库';
break;
default:
$name = '';
}
return $name;
}
public function getLib()
{
if($this->location == 1)
return null;
if($this->location == 2)
return $this->hasOne(CarBT::className(),['id'=>'id']);
if($this->location == 3)
return $this->hasOne(CarCT::className(),['id'=>'id']);
if($this->location == 4)
return $this->hasOne(CarDT::className(),['id'=>'id']);
if($this->location == 5)
return $this->hasOne(CarInvalidT::className(),['id'=>'id']);
return null;
}
}