|
@@ -1,6 +1,8 @@
|
|
|
<?php
|
|
|
namespace App\Repositories;
|
|
|
use App\Models\Floor;
|
|
|
+use App\Models\TopicGroup;
|
|
|
+use App\Models\TopicGroupInfo;
|
|
|
use App\Traits\UserTrait;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
@@ -18,9 +20,13 @@ use Illuminate\Database\QueryException;
|
|
|
class FloorRepository
|
|
|
{
|
|
|
use UserTrait;
|
|
|
- public function __construct(Floor $floor)
|
|
|
+ public function __construct(Floor $floor,
|
|
|
+ TopicGroup $topicGroup,
|
|
|
+ TopicGroupInfo $topicGroupInfo)
|
|
|
{
|
|
|
$this->floor = $floor;
|
|
|
+ $this->topicGroup = $topicGroup;
|
|
|
+ $this->topicGroupInfo = $topicGroupInfo;
|
|
|
}
|
|
|
|
|
|
public function index($request)
|
|
@@ -38,7 +44,7 @@ class FloorRepository
|
|
|
if(!$userInfo){
|
|
|
return jsonError('获取用户信息失败');
|
|
|
}
|
|
|
- return $floor = $this->floor
|
|
|
+ $floor = $this->floor
|
|
|
->where('is_open', 1)
|
|
|
->whereIn('floor_type', [0,1,2,3])
|
|
|
->whereBetween('floor_location', [1,20])
|
|
@@ -47,14 +53,36 @@ class FloorRepository
|
|
|
foreach($floor as $item){
|
|
|
if($item->floor_type == 0){
|
|
|
//banner
|
|
|
+ $banner = $this->getBanner($item->group_ids);
|
|
|
+ if($banner){
|
|
|
+ $data[$item->floor_location] = [
|
|
|
+ 'show_type' => 'banner',
|
|
|
+ 'data' => $banner
|
|
|
+ ];
|
|
|
+ }
|
|
|
}elseif($item->floor_type == 1){
|
|
|
//user
|
|
|
}elseif($item->floor_type == 2){
|
|
|
//video
|
|
|
}elseif($item->floor_type == 3){
|
|
|
//topic
|
|
|
+ $topicIds = $this->topicGroup
|
|
|
+ ->join('topic_group_info', 'topic_group_info.topic_group_id', '=', 'topic_group.id')
|
|
|
+ ->where('topic_group.id', $item->group_ids)
|
|
|
+ ->limit(20)
|
|
|
+ ->pluck('topic_group_info.topic_id')
|
|
|
+ ->toArray();
|
|
|
+ $topicIds = implode($topicIds, ',');
|
|
|
+ $topic = $this->getTopic($topicIds);
|
|
|
+ if($topic){
|
|
|
+ $data[$item->floor_location] = [
|
|
|
+ 'show_type' => 'topic',
|
|
|
+ 'data' => $topic
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ return $data;
|
|
|
}
|
|
|
|
|
|
}
|