调整页面

This commit is contained in:
2022-03-04 17:05:16 +08:00
parent 42ba67e4bb
commit 7037180850
4 changed files with 1253 additions and 1120 deletions

View File

@@ -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;