55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?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)
|
|
->where('status', 1)
|
|
->orderBy('created_at', 'desc')
|
|
->paginate(5);
|
|
|
|
return view('articles.index', compact('articles', 'category'));
|
|
}
|
|
|
|
public function show(Article $article)
|
|
{
|
|
if ($article->url) {
|
|
return redirect($article->url);
|
|
}
|
|
|
|
$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'));
|
|
}
|
|
|
|
}
|