|
@@ -87,24 +87,23 @@ class IndexController extends Controller
|
|
*/
|
|
*/
|
|
public function home(Request $request)
|
|
public function home(Request $request)
|
|
{
|
|
{
|
|
|
|
+ $arr1 =DreamInfoModel::orderBy('score','desc')->limit(20)->select('id')->get()->toArray();
|
|
|
|
+ $id_arr1 = array_column($arr1,'id');
|
|
|
|
+ $arr2 =DreamInfoModel::orderBy('score','desc')->limit(120)->select('id')->get()->toArray();
|
|
|
|
+ $id_arr2 = array_column($arr2,'id');
|
|
$users = [];
|
|
$users = [];
|
|
$type = $request->type;
|
|
$type = $request->type;
|
|
if ($type == 'trend') {
|
|
if ($type == 'trend') {
|
|
- $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->offset(20)->limit(100)->paginate(15);
|
|
|
|
-// dd($dreams);
|
|
|
|
-
|
|
|
|
|
|
+ $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->whereNotIn('id', $id_arr1)->limit(100)->paginate(20);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
return $this->api(compact('users','dreams'));
|
|
return $this->api(compact('users','dreams'));
|
|
} elseif ($type == 'news') {
|
|
} elseif ($type == 'news') {
|
|
- $dreams = DreamInfoModel::orderBy('score','desc')->orderBy('created_at','desc')->with('user')->limit(500)->offset(100)->paginate(15);
|
|
|
|
-// dd($dreams);
|
|
|
|
-
|
|
|
|
|
|
+ $dreams = DreamInfoModel::orderBy('score','desc')->orderBy('created_at','desc')->with('user')->whereNotIn('id', $id_arr2)->limit(500)->paginate(20);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
return $this->api(compact('users','dreams'));
|
|
return $this->api(compact('users','dreams'));
|
|
} else{
|
|
} else{
|
|
$banners = $this->getBanner();
|
|
$banners = $this->getBanner();
|
|
- $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->limit(20)->paginate(15);
|
|
|
|
-// dd($dreams);
|
|
|
|
|
|
+ $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->limit(20)->paginate(20);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
return $this->api(compact('banners','users','dreams'));
|
|
return $this->api(compact('banners','users','dreams'));
|
|
}
|
|
}
|