| | |
| | | public function logoImage() |
| | | { |
| | | $model = self::getCalledModule() ?: 'common'; |
| | | return $this->hasOne("app\\$model\\model\\file\\UploadFile", 'file_id', 'logo')->bind(['file_path']); |
| | | return $this->hasOne("app\\$model\\model\\file\\UploadFile", 'file_id', 'logo'); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | $model = self::getCalledModule() ?: 'common'; |
| | | return $this->hasOne("app\\$model\\model\\plus\\business\\Grade", 'grade_id', 'grade_id'); |
| | | } |
| | | public function industry() |
| | | { |
| | | $model = self::getCalledModule() ?: 'common'; |
| | | return $this->hasOne("app\\$model\\model\\plus\\business\\Industry", 'industry_id', 'industry_id'); |
| | | } |
| | | |
| | | /** |
| | |
| | | !empty($paramr['province_id']) && $where['province_id'] = $paramr['province_id']; |
| | | !empty($paramr['city_id']) && $where['city_id'] = $paramr['city_id']; |
| | | !empty($paramr['region_id']) && $where['region_id'] = $paramr['region_id']; |
| | | // 检查置顶时间是否过期,如果过期则设置为非置顶 |
| | | $this->checkTopExpire(); |
| | | if (!empty($paramr['sort'])) { |
| | | $order = ['is_top' => 'desc', 'top_time' => 'desc']; |
| | | if ($paramr['sort'] == 'name') { |
| | | $order = ['name' => "asc"]; |
| | | $order['name'] = "asc"; |
| | | } else if ($paramr['sort'] == 'time') { |
| | | $order = ['create_time' => "asc"]; |
| | | $order['create_time'] = "asc"; |
| | | } else { |
| | | $order = ['unit' => "asc"]; |
| | | $order['unit'] = "asc"; |
| | | } |
| | | } else { |
| | | $order = ['is_default' => 'desc', 'create_time' => 'desc']; |
| | | // 按置顶状态和创建时间排序 |
| | | $order = ['is_top' => 'desc', 'top_time' => 'desc', 'create_time' => 'desc']; |
| | | } |
| | | return $this->with(['user', 'image', 'logoImage', 'grade'])->order($order)->where($where)->paginate($paramr); |
| | | } |
| | | |
| | | /** |
| | | * 检查并更新过期的置顶名片 |
| | | */ |
| | | private function checkTopExpire() |
| | | { |
| | | $this->where('is_top', 1) |
| | | ->where('top_time', '<', time()) |
| | | ->update(['is_top' => 0]); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static function detail($business_card_id) |
| | | { |
| | | return (new self())->with(['user', 'image', 'logoImage', 'grade'])->where(['business_card_id' => $business_card_id])->find(); |
| | | return (new self())->with(['user', 'image', 'logoImage', 'grade', 'industry'])->where(['business_card_id' => $business_card_id])->find(); |
| | | } |
| | | } |