FSpcCar.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\modules\car\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%f_spc_car}}".
  6. *
  7. * @property int $id
  8. * @property string $card_num
  9. * @property int $is_spec
  10. * @property string $bak
  11. * @property string $dept
  12. */
  13. class FSpcCar extends \app\common\models\EActiveRecord
  14. {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public static function tableName()
  19. {
  20. return '{{%f_spc_car}}';
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function rules()
  26. {
  27. return [
  28. [['is_spec'], 'integer'],
  29. [['card_num'], 'string', 'max' => 50],
  30. [['bak', 'dept'], 'string', 'max' => 100],
  31. ];
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function attributeLabels()
  37. {
  38. return [
  39. 'id' => 'ID',
  40. 'card_num' => '车牌号码',
  41. 'is_spec' => '特殊车辆',
  42. 'bak' => '说明',
  43. 'dept' => '所属单位',
  44. ];
  45. }
  46. public function dptOptions($k=NULL)
  47. {
  48. $resultList = Yii::$app->db->createCommand("select distinct(dept) from {{%f_spc_car}}")->queryAll();
  49. $options = [];
  50. if(is_array($resultList))foreach($resultList as $result)
  51. {
  52. $options[$result['dept']] = $result['dept'];
  53. }
  54. if($k)return $options[$k];
  55. return $options;
  56. }
  57. }