This commit is contained in:
2020-11-05 13:27:12 +08:00
parent 38eff9579c
commit 393552f498
5 changed files with 155 additions and 132 deletions

View File

@@ -8,11 +8,13 @@ use App\Models\Category;
class ArticleController extends Controller
{
public function index(Category $category)
{
$articles = Article::where('category_id', $category->id)
->orderBy('created_at', 'desc')
->paginate(5);
->where('status', 1)
->orderBy('created_at', 'desc')
->paginate(5);
return view('articles.index', compact('articles', 'category'));
}
@@ -20,6 +22,7 @@ class ArticleController extends Controller
public function show(Article $article)
{
$category = $article->category;
return view('articles.show', compact('article', 'category'));
}
@@ -33,8 +36,9 @@ class ArticleController extends Controller
public function picture(Category $category)
{
$articles = ArticlePicture::where('category_id', $category->id)
->orderBy('created_at', 'desc')
->paginate(12);
->orderBy('created_at', 'desc')
->paginate(12);
return view('articles.picture', compact('articles', 'category'));
}
@@ -42,4 +46,5 @@ class ArticleController extends Controller
{
return view('articles.picshow', compact('article'));
}
}