|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace App\Http\Controllers\Web\Content;
|
|
|
|
|
|
use App\Http\Controllers\Web\WebBaseController;
|
|
@@ -25,20 +26,20 @@ class ArticleController extends WebBaseController
|
|
|
*/
|
|
|
public function __construct(ArticleService $articleService, ArticleCategoryService $articleCategoryService, AdService $adService, NavigationService $navigationService)
|
|
|
{
|
|
|
- $this->articleService = $articleService;
|
|
|
+ $this->articleService = $articleService;
|
|
|
$this->articleCategoryService = $articleCategoryService;
|
|
|
- $this->adService = $adService;
|
|
|
- $this->navigationService = $navigationService;
|
|
|
+ $this->adService = $adService;
|
|
|
+ $this->navigationService = $navigationService;
|
|
|
}
|
|
|
|
|
|
public function index(Request $request, $id = '1', $num = '8', $focus = '3', $recommend = '4', $other_num = '5')
|
|
|
{
|
|
|
- $key = $request->input('key');
|
|
|
+ $key = $request->input('key');
|
|
|
$categorys = $this->articleCategoryService->getChildCategorys($id, $num);
|
|
|
$search_id = '';
|
|
|
if ($categorys) {
|
|
|
- $search_id = $categorys[0]->id;
|
|
|
- $search_where = array();
|
|
|
+ $search_id = $categorys[0]->id;
|
|
|
+ $search_where = [];
|
|
|
$search_where['id'] = $search_id;
|
|
|
if ($id != '1') {
|
|
|
$search_where['parent_id'] = $id;
|
|
@@ -60,71 +61,76 @@ class ArticleController extends WebBaseController
|
|
|
$rst = $this->articleService->list($key, '', 10);
|
|
|
}
|
|
|
|
|
|
- $focus_articles = $this->articleService->getPropertyArticles($focus, $other_num); //热门资讯
|
|
|
+ $focus_articles = $this->articleService->getPropertyArticles($focus, $other_num); //热门资讯
|
|
|
$recommend_articles = $this->articleService->getPropertyArticles($recommend, $other_num); //推荐资讯
|
|
|
//顶部广告位
|
|
|
- $ad_data = array(
|
|
|
- 'theme' => 'default',
|
|
|
- 'org' => 'Home',
|
|
|
- 'alias' => 'AIX_news_index_top',
|
|
|
- 'num' => '1'
|
|
|
- );
|
|
|
+ $ad_data = [
|
|
|
+ 'theme' => 'default',
|
|
|
+ 'org' => 'Home',
|
|
|
+ 'alias' => 'AIX_news_index_top',
|
|
|
+ 'num' => '1',
|
|
|
+ ];
|
|
|
$top_ads = $this->adService->getAds($ad_data);
|
|
|
|
|
|
- $return_data = array(
|
|
|
+ $return_data = [
|
|
|
'articles' => $rst,
|
|
|
'categorys' => $categorys,
|
|
|
'focus_articles' => $focus_articles,
|
|
|
'recommend_articles' => $recommend_articles,
|
|
|
- 'key' => $key,
|
|
|
- 'top_ads' => $top_ads
|
|
|
- );
|
|
|
+ 'key' => $key,
|
|
|
+ 'top_ads' => $top_ads,
|
|
|
+ ];
|
|
|
return view('app.content.article.index', $return_data);
|
|
|
}
|
|
|
|
|
|
public function list(Request $request, $id, $parent_id = '1', $num = '8', $focus = '3', $recommend = '4', $other_num = '5')
|
|
|
{
|
|
|
- $key = $request->input('key');
|
|
|
- $lists = $this->articleService->list($key, $id, '10');
|
|
|
- $categorys = $this->articleCategoryService->getChildCategorys($parent_id, $num);
|
|
|
- $focus_articles = $this->articleService->getPropertyArticles($focus, $other_num); //热门资讯
|
|
|
+ $key = $request->input('key');
|
|
|
+ $info = $this->articleCategoryService->getInfo($id);
|
|
|
+ $lists = $this->articleService->list($key, $id, '10');
|
|
|
+ $categorys = $this->articleCategoryService->getChildCategorys($info['parent_id'], $num);
|
|
|
+ $categorys_child = $this->articleCategoryService->getChildCategorys($id, 10);
|
|
|
+ $focus_articles = $this->articleService->getPropertyArticles($focus, $other_num); //热门资讯
|
|
|
$recommend_articles = $this->articleService->getPropertyArticles($recommend, $other_num); //推荐资讯
|
|
|
+ $bread = $this->articleCategoryService->getBread($info['id']);
|
|
|
|
|
|
//获取后台职场资讯名称
|
|
|
- $where = array(
|
|
|
- 'alias'=>'AIX_top',
|
|
|
+ $where = [
|
|
|
+ 'alias' => 'AIX_top',
|
|
|
'pagealias' => 'AIX_news',
|
|
|
- 'display'=>'1'
|
|
|
- );
|
|
|
- $topNav = $this->navigationService->getTopNav($where);
|
|
|
- $now_cate = '';
|
|
|
- $article_cate = array();
|
|
|
+ 'display' => '1',
|
|
|
+ ];
|
|
|
+ $topNav = $this->navigationService->getTopNav($where);
|
|
|
+ $now_cate = '';
|
|
|
+ $article_cate = [];
|
|
|
foreach ($categorys as $k => $v) {
|
|
|
if ($v->id == $id) {
|
|
|
- $now_cate = $v->category_name;
|
|
|
+ $now_cate = $v->category_name;
|
|
|
$article_cate = $v;
|
|
|
}
|
|
|
}
|
|
|
$this->putSeoData('article_cate', $article_cate);
|
|
|
|
|
|
- $return_data = array(
|
|
|
- 'articles'=>$lists,
|
|
|
- 'categorys'=>$categorys,
|
|
|
- 'focus_articles'=>$focus_articles,
|
|
|
- 'recommend_articles'=>$recommend_articles,
|
|
|
- 'key'=>$key,
|
|
|
- 'type_id'=>$id,
|
|
|
- 'top_nav'=>$topNav,
|
|
|
- 'now_cate'=>$now_cate,
|
|
|
- );
|
|
|
+ $return_data = [
|
|
|
+ 'articles' => $lists,
|
|
|
+ 'categorys' => $categorys,
|
|
|
+ 'focus_articles' => $focus_articles,
|
|
|
+ 'recommend_articles' => $recommend_articles,
|
|
|
+ 'key' => $key,
|
|
|
+ 'type_id' => $id,
|
|
|
+ 'top_nav' => $topNav,
|
|
|
+ 'now_cate' => $now_cate,
|
|
|
+ 'categorys_child' => $categorys_child,
|
|
|
+ 'bread' => $bread,
|
|
|
+ ];
|
|
|
|
|
|
return view('app.content.article.list', $return_data);
|
|
|
}
|
|
|
|
|
|
public function show($id, $parent_id = '1', $num = '8', $focus = '3', $recommend = '4', $other_num = '5')
|
|
|
{
|
|
|
- $categorys = $this->articleCategoryService->getChildCategorys($parent_id, $num);
|
|
|
- $focus_articles = $this->articleService->getPropertyArticles($focus, $other_num); //热门资讯
|
|
|
+ $categorys = $this->articleCategoryService->getChildCategorys($parent_id, $num);
|
|
|
+ $focus_articles = $this->articleService->getPropertyArticles($focus, $other_num); //热门资讯
|
|
|
$recommend_articles = $this->articleService->getPropertyArticles($recommend, $other_num); //推荐资讯
|
|
|
|
|
|
$article_info = $this->articleService->getArticleInfo($id);
|
|
@@ -135,24 +141,24 @@ class ArticleController extends WebBaseController
|
|
|
|
|
|
$this->putSeoData('article', $article_info);
|
|
|
|
|
|
- $return_data = array(
|
|
|
- 'categorys'=>$categorys,
|
|
|
- 'focus_articles'=>$focus_articles,
|
|
|
- 'recommend_articles'=>$recommend_articles,
|
|
|
- 'type_id'=>$id,
|
|
|
- 'info'=>$article_info,
|
|
|
- 'parent_id'=>$parent_id
|
|
|
- );
|
|
|
+ $return_data = [
|
|
|
+ 'categorys' => $categorys,
|
|
|
+ 'focus_articles' => $focus_articles,
|
|
|
+ 'recommend_articles' => $recommend_articles,
|
|
|
+ 'type_id' => $id,
|
|
|
+ 'info' => $article_info,
|
|
|
+ 'parent_id' => $parent_id,
|
|
|
+ ];
|
|
|
|
|
|
return view('app.content.article.show', $return_data);
|
|
|
}
|
|
|
|
|
|
public function click($id)
|
|
|
{
|
|
|
- $rst = $this->articleService->incrementData(array('id'=>$id), 1, 'click');
|
|
|
- $data = array('status'=>0);
|
|
|
+ $rst = $this->articleService->incrementData(['id' => $id], 1, 'click');
|
|
|
+ $data = ['status' => 0];
|
|
|
if ($rst) {
|
|
|
- $data = array('status'=>1);
|
|
|
+ $data = ['status' => 1];
|
|
|
}
|
|
|
return response()->json($data);
|
|
|
}
|