WorkerPic.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. /**
  12. * This is the model class for table "{{%worker_pic}}".
  13. *
  14. * @property integer $id
  15. */
  16. class WorkerPic extends \yii\db\ActiveRecord
  17. {
  18. /**
  19. * @inheritdoc
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%worker_pic}}';
  24. }
  25. public function behaviors()
  26. {
  27. return [];
  28. }
  29. //增加或者全部替换
  30. public static function saveAll($worker_id, $pics = [], $delAll = 0) {
  31. if($delAll){
  32. self::updateAll(['is_delete' => 1], ['worker_id' => $worker_id]);
  33. }
  34. foreach($pics as $pic){
  35. $self = new self();
  36. $self->worker_id = $worker_id;
  37. $self->pic_url = $pic;
  38. $self->save();
  39. }
  40. return true;
  41. }
  42. public static function del($worker_id, $ids = []) {
  43. return self::updateAll(['is_delete' => 1], ['worker_id' => $worker_id, 'id' => $ids]);
  44. }
  45. }