save($data); } /** * 编辑记录 */ public function edit($data) { return $this->save($data); } /** * 删除记录 * @return bool|int */ public function setDelete() { return $this->save(['is_delete' => 1]); } /** * 检查是否有默认档口,没有则添加 */ public static function checkDefault($shop_supplier_id) { $model = (new static); $count = $model->where('shop_supplier_id', '=', $shop_supplier_id)->where('is_default', '=', 1)->count(); if (!$count) { $data = []; $stallType = StallTypeEnum::data(); foreach ($stallType as $type) { $data[] = [ 'stall_name' => $type['name'], 'stall_type' => $type['value'], 'is_default' => 1, 'shop_supplier_id' => $shop_supplier_id, 'app_id' => self::$app_id, ]; } $model->saveAll($data); } return true; } }