Completed
Push — master ( bd60cc...5acf9c )
by
07:14 queued 01:21
created

FaqController::showArticlePage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Qsnh/meedu.
5
 *
6
 * (c) XiaoTeng <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace App\Http\Controllers\Frontend;
13
14
use App\Models\FaqArticle;
15
use App\Models\FaqCategory;
16
use App\Http\Controllers\Controller;
17
18
class FaqController extends Controller
19
{
20
    public function index()
21
    {
22
        $categories = FaqCategory::all();
23
24
        return view('frontend.faq.index', compact('categories'));
25
    }
26
27
    public function showCategoryPage($categoryId)
28
    {
29
        $category = FaqCategory::findOrFail($categoryId);
30
        $categories = FaqCategory::all();
31
        $articles = $category->articles()->orderByDesc('updated_at')->paginate(15);
32
33
        return view('frontend.faq.category_detail', compact('category', 'categories', 'articles'));
34
    }
35
36
    public function showArticlePage($articleId)
37
    {
38
        $article = FaqArticle::findOrFail($articleId);
39
        $categories = FaqCategory::all();
40
41
        return view('frontend.faq.article_detail', compact('article', 'categories'));
42
    }
43
}
44