修改
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Advert;
|
||||
use App\Models\Article;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
@@ -27,4 +28,18 @@ class ArticleController extends Controller
|
||||
|
||||
}
|
||||
|
||||
//搜索
|
||||
public function search(Request $request)
|
||||
{
|
||||
$title = $request->title;
|
||||
$articles = Article::where('status', 1)
|
||||
->when($title, function ($q) use ($title) {
|
||||
$q->where('title', 'like', "%{$title}%");
|
||||
})
|
||||
->paginate();
|
||||
|
||||
return view('article.search', compact('articles'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class CategoryController extends Controller
|
||||
} else {
|
||||
$articles = $category->relations(Category::TYPE_ARTICLE)->paginate(8);
|
||||
$parent = $category;
|
||||
if ($category->childrens->isEmpty()) {
|
||||
if ($category->childrens->isEmpty() && $category->patent) {
|
||||
$parent = $category->parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class Controller extends BaseController
|
||||
$categorys = Category::where('status', 1)
|
||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
||||
->where('top_show', 1)
|
||||
->orderBy('order', 'desc')
|
||||
->orderBy('order', 'asc')
|
||||
->select('id', 'title')
|
||||
->get();
|
||||
$links = Link::get();
|
||||
|
||||
Reference in New Issue
Block a user