|
|
|
|
11
|
use App\Models\UserMessage;
|
11
|
use App\Models\UserMessage;
|
12
|
use App\Models\Special;
|
12
|
use App\Models\Special;
|
13
|
use App\Models\News;
|
13
|
use App\Models\News;
|
|
|
14
|
+use App\Models\NewsCategory;
|
14
|
use Illuminate\Http\Request;
|
15
|
use Illuminate\Http\Request;
|
15
|
use Solr;
|
16
|
use Solr;
|
16
|
use DB;
|
17
|
use DB;
|
|
|
|
|
278
|
public function articleList(Request $request){
|
279
|
public function articleList(Request $request){
|
279
|
$page=$request->has('page')?$request->input('page'):1;
|
280
|
$page=$request->has('page')?$request->input('page'):1;
|
280
|
$start=intval((intval($page)-1)*intval(20));
|
281
|
$start=intval((intval($page)-1)*intval(20));
|
281
|
- $data=News::where('status',1)->select('id','imgurl','title','createTime')->orderBy('createTime','desc')->offset($start)->limit(20)->get();
|
|
|
|
|
282
|
+ $type=NewsCategory::pluck('name','abbreviation');
|
|
|
283
|
+ $data=News::where('status',1)->select('id','imgurl','title','createTime','category','readNum')->orderBy('createTime','desc')->offset($start)->limit(20)->get();
|
|
|
284
|
+ $data=json_decode(json_encode($data),true);
|
|
|
285
|
+ foreach($data as $key=>$item){
|
|
|
286
|
+ $data[$key]['category']=$type[$item['category']];
|
|
|
287
|
+ }
|
282
|
return $this->response->array(self::returnValue(['data' => $data], 200));
|
288
|
return $this->response->array(self::returnValue(['data' => $data], 200));
|
283
|
}
|
289
|
}
|
284
|
public function articleDetail(Request $request){
|
290
|
public function articleDetail(Request $request){
|
285
|
$id=$request->input('id');
|
291
|
$id=$request->input('id');
|
286
|
$articleDetail=News::where('id',$id)->first();
|
292
|
$articleDetail=News::where('id',$id)->first();
|
|
|
293
|
+ $type=NewsCategory::pluck('name','abbreviation');
|
|
|
294
|
+ $articleDetail['category']=$type[$articleDetail['category']];
|
287
|
$articleDetail['content'] = str_replace(array("\r\n", "\r", "\n"), "", $articleDetail['content']);
|
295
|
$articleDetail['content'] = str_replace(array("\r\n", "\r", "\n"), "", $articleDetail['content']);
|
288
|
return $this->response->array(self::returnValue(['data' => $articleDetail], 200));
|
296
|
return $this->response->array(self::returnValue(['data' => $articleDetail], 200));
|
289
|
}
|
297
|
}
|