with('user') ->order(['create_time' => 'desc']) ->where($data) ->paginate(18); } /** * 新增记录 * @param $data * @param array $user * @return bool|false|int * @throws \think\exception\DbException */ public function add($data, $user = []) { $this->startTrans(); try { if(isset($data['card_number'])){ $data['store_user_id'] = $user['store_user_id']; $data['store_id'] = self::$storeId; $this->save($data); }else { foreach ($data as &$item){ $item['store_user_id'] = $user['store_user_id']; $item['store_id'] = self::$storeId; } $this->saveAll($data); } $this->commit(); return true; } catch (\Exception $e) { $this->error = $e->getMessage(); $this->rollback(); return false; } } /** * 软删除 * @return false|int */ public function setDelete() { return $this->save(['is_delete'=>1]); } }