FStatsCostHkm.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\modules\car\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%f_stats_cost_hkm}}".
  6. *
  7. * @property int $id 序号
  8. * @property int $car_id 外键关联f_car_infor(car_id)
  9. * @property float|null $opt_cost_hkm 百公里运行费
  10. * @property float|null $sum_costs_per_km 百公里费用
  11. * @property int|null $year 年
  12. * @property int|null $month 月
  13. */
  14. class FStatsCostHkm extends \app\common\models\EActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return '{{%f_stats_cost_hkm}}';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['car_id'], 'required'],
  30. [['car_id', 'year', 'month'], 'integer'],
  31. [['opt_cost_hkm', 'sum_costs_per_km'], 'number'],
  32. ];
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => '序号',
  41. 'car_id' => '外键关联f_car_infor(car_id)',
  42. 'opt_cost_hkm' => '百公里运行费',
  43. 'sum_costs_per_km' => '百公里费用',
  44. 'year' => '年',
  45. 'month' => '月',
  46. ];
  47. }
  48. public function getCarinfo()
  49. {
  50. return FCarInfo::find()->where("car_id=$this->car_id")->limit(1)->one();
  51. }
  52. }