| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%worker_pic}}".
- *
- * @property integer $id
- */
- class WorkerPic extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%worker_pic}}';
- }
- public function behaviors()
- {
- return [];
- }
-
- //增加或者全部替换
- public static function saveAll($worker_id, $pics = [], $delAll = 0) {
- if($delAll){
- self::updateAll(['is_delete' => 1], ['worker_id' => $worker_id]);
- }
- foreach($pics as $pic){
- $self = new self();
- $self->worker_id = $worker_id;
- $self->pic_url = $pic;
- $self->save();
- }
- return true;
- }
- public static function del($worker_id, $ids = []) {
- return self::updateAll(['is_delete' => 1], ['worker_id' => $worker_id, 'id' => $ids]);
- }
- }
|