|
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\Backend; |
|
13
|
|
|
|
|
14
|
|
|
use App\Models\FaqArticle; |
|
15
|
|
|
use App\Models\FaqCategory; |
|
16
|
|
|
use App\Http\Controllers\Controller; |
|
17
|
|
|
use App\Http\Requests\Backend\FaqArticleRequest; |
|
18
|
|
|
|
|
19
|
|
|
class FaqArticleController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
public function index() |
|
22
|
|
|
{ |
|
23
|
|
|
$articles = FaqArticle::with('category')->orderByDesc('updated_at')->paginate(15); |
|
24
|
|
|
|
|
25
|
|
|
return view('backend.faq_article.index', compact('articles')); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function create() |
|
29
|
|
|
{ |
|
30
|
|
|
$categories = FaqCategory::all(); |
|
31
|
|
|
|
|
32
|
|
|
return view('backend.faq_article.create', compact('categories')); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function store(FaqArticleRequest $request) |
|
36
|
|
|
{ |
|
37
|
|
|
FaqArticle::create($request->filldata()); |
|
38
|
|
|
flash('添加成功', 'success'); |
|
39
|
|
|
|
|
40
|
|
|
return back(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function edit($id) |
|
44
|
|
|
{ |
|
45
|
|
|
$article = FaqArticle::findOrFail($id); |
|
46
|
|
|
$categories = FaqCategory::all(); |
|
47
|
|
|
|
|
48
|
|
|
return view('backend.faq_article.edit', compact('article', 'categories')); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function update(FaqArticleRequest $request, $id) |
|
52
|
|
|
{ |
|
53
|
|
|
$article = FaqArticle::findOrFail($id); |
|
54
|
|
|
$article->fill($request->filldata())->save(); |
|
55
|
|
|
flash('编辑成功', 'success'); |
|
56
|
|
|
|
|
57
|
|
|
return back(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function destroy($id) |
|
61
|
|
|
{ |
|
62
|
|
|
$article = FaqArticle::findOrFail($id); |
|
63
|
|
|
$article->delete(); |
|
64
|
|
|
flash('删除成功', 'success'); |
|
65
|
|
|
|
|
66
|
|
|
return back(); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|