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

FaqController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 5 1
A showArticlePage() 0 6 1
A showCategoryPage() 0 7 1
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