belongsTo("app\\{$module}\\model\\store\\User", 'store_user_id'); } /** * 结账详情 * @param $where * @param array $with * @return static|null * @throws \think\exception\DbException */ public static function detail($where, $with = []) { !is_array($where) && $where = ['checkout_id' => (int)$where]; return static::get($where, $with); } /** * 获取全部 * @return mixed */ public static function getAll() { $model = new static; return $model->order(['checkout_id' => 'asc'])->select(); } /** * 开始时间 * @param $value * @return false|string */ public function getStartTimeAttr($value) { return format_time($value); } /** * 结束时间 * @param $value * @return false|string */ public function getEndTimeAttr($value) { return format_time($value); } /** * 获取指定 * @param array $filter * @return mixed */ public static function getQuery($filter): array { $model = new static; return $model->where($filter)->order(['checkout_id' => 'asc'])->select()->toArray(); } /** * 获取最新一条记录 * @param array $filter * @return array|null */ public static function getSingle(array $filter = []): ?array { $model = new static; $data = $model->where($filter)->order(['checkout_id' => 'desc'])->find(); return $data ? $data->toArray() : null; } }