调整页面
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Advert;
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
|
||||
class CategoryController extends Controller
|
||||
@@ -10,20 +11,28 @@ class CategoryController extends Controller
|
||||
|
||||
/**
|
||||
* 显示分类
|
||||
*
|
||||
* @param Category $category [description]
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View [type] [description]
|
||||
*/
|
||||
public function index(Category $category)
|
||||
{
|
||||
if ($category->type == Category::TYPE_SHOW && $category->article_id) {
|
||||
return redirect("articles/" . $category->article_id);
|
||||
return redirect("articles/".$category->article_id);
|
||||
} else {
|
||||
$articles = $category->relations(Category::TYPE_ARTICLE)
|
||||
->where('status', 1)
|
||||
->latest('sort')
|
||||
->latest()
|
||||
->paginate();
|
||||
$parent = $category;
|
||||
// $articles = $category->relations(Category::TYPE_ARTICLE)
|
||||
// ->where('status', 1)
|
||||
// ->latest('sort')
|
||||
// ->latest()
|
||||
// ->paginate();
|
||||
|
||||
$articles = Article::ByCategory($category->getAllChildrenId())
|
||||
->where('status', 1)
|
||||
->latest()
|
||||
->latest('created_at')
|
||||
->paginate();
|
||||
|
||||
$parent = $category;
|
||||
|
||||
if ($category->childrens->isEmpty() && $category->parent) {
|
||||
$parent = $category->parent;
|
||||
|
||||
Reference in New Issue
Block a user