firstpush
This commit is contained in:
45
app/Http/Controllers/ArticleController.php
Normal file
45
app/Http/Controllers/ArticleController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\ArticlePicture;
|
||||
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);
|
||||
|
||||
return view('articles.index', compact('articles', 'category'));
|
||||
}
|
||||
|
||||
public function show(Article $article)
|
||||
{
|
||||
$category = $article->category;
|
||||
return view('articles.show', compact('article', 'category'));
|
||||
}
|
||||
|
||||
public function category(Category $category)
|
||||
{
|
||||
$article = Article::where('category_id', $category->id)->first();
|
||||
|
||||
return view('articles.show', compact('article'));
|
||||
}
|
||||
|
||||
public function picture(Category $category)
|
||||
{
|
||||
$articles = ArticlePicture::where('category_id', $category->id)
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(12);
|
||||
return view('articles.picture', compact('articles', 'category'));
|
||||
}
|
||||
|
||||
public function picshow(ArticlePicture $article)
|
||||
{
|
||||
return view('articles.picshow', compact('article'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user