This commit is contained in:
2020-09-17 08:57:27 +08:00
parent ac3b53b163
commit a4162b5710
9 changed files with 223 additions and 157 deletions

View File

@@ -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'));
}
}

View File

@@ -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;
}

View File

@@ -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();