调整简历+文章增加外链
This commit is contained in:
@@ -11,18 +11,22 @@ class ArticleController extends Controller
|
||||
|
||||
/**
|
||||
* 显示分类
|
||||
* @param \App\Models\Article $article
|
||||
*
|
||||
* @param \App\Models\Article $article
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View [type] [description]
|
||||
*/
|
||||
public function show(Article $article)
|
||||
{
|
||||
if ($article->url) {
|
||||
return redirect()->away($article->url);
|
||||
}
|
||||
$categories = $article->categories;
|
||||
$next = Article::where('id', '>', $article->id)
|
||||
->whereHas('categories', function ($q) use ($categories) {
|
||||
$q->whereIN('id', $categories->pluck('id'));
|
||||
})
|
||||
->where('status', 1)
|
||||
->first();
|
||||
->whereHas('categories', function ($q) use ($categories) {
|
||||
$q->whereIN('id', $categories->pluck('id'));
|
||||
})
|
||||
->where('status', 1)
|
||||
->first();
|
||||
|
||||
return view('article.show', compact('article', 'next'));
|
||||
|
||||
@@ -33,12 +37,12 @@ class ArticleController extends Controller
|
||||
{
|
||||
$title = $request->title;
|
||||
$articles = Article::where('status', 1)
|
||||
->when($title, function ($q) use ($title) {
|
||||
$q->where('title', 'like', "%{$title}%")
|
||||
->orWhere('content', 'like', "%{$title}%");
|
||||
})
|
||||
->latest()
|
||||
->paginate();
|
||||
->when($title, function ($q) use ($title) {
|
||||
$q->where('title', 'like', "%{$title}%")
|
||||
->orWhere('content', 'like', "%{$title}%");
|
||||
})
|
||||
->latest()
|
||||
->paginate();
|
||||
|
||||
return view('article.search', compact('articles'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user