Add (article): ai gen, front views

This commit is contained in:
2023-09-24 22:53:40 +08:00
parent 18705bd5e4
commit 322d680961
115 changed files with 9710 additions and 201 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Post;
use Illuminate\Http\Request;
class FrontListController extends Controller
{
public function index(Request $request)
{
$posts = Post::where('status', 'publish')->orderBy('published_at', 'desc')->simplePaginate(10) ?? collect();
return view('front.post_list', compact('posts'));
}
public function category(Request $request, $category_slug)
{
$category = Category::where('slug', $category_slug)->first();
$posts = $category?->posts()->where('status', 'publish')->orderBy('published_at', 'desc')->simplePaginate(10) ?? collect();
return view('front.post_list', compact('category', 'posts'));
}
}