-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFaqController.php
executable file
·69 lines (57 loc) · 1.81 KB
/
FaqController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace App\Http\Controllers;
use App\Faq;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
class FaqController extends Controller
{
public function createFaqs()
{
$data['page_title'] = "Create New Faq";
return view('admin.faqs.create',$data);
}
public function storeFaqs(Request $request)
{
$request->validate([
'title' => 'required',
'description' => 'required'
]);
$in = Input::except('_method','_token');
Faq::create($in);
$notification = array('message' => 'FAQS Created Successfully.', 'alert-type' => 'success');
return back()->with($notification);
}
public function allFaqs()
{
$data['page_title'] = "All Question";
$data['faqs'] = Faq::orderBy('id','desc')->paginate(10);
return view('admin.faqs.index',$data);
}
public function editFaqs($id)
{
$data['page_title'] = "Edit Faqs";
$data['faqs'] = Faq::findOrFail($id);
return view('admin.faqs.edit',$data);
}
public function updateFaqs(Request $request, $id)
{
$faqs = Faq::findOrFail($id);
$request->validate([
'title' => 'required',
'description' => 'required'
]);
$in = Input::except('_method','_token');
$faqs->fill($in)->save();
$notification = array('message' => 'FAQS Updated Successfully.', 'alert-type' => 'success');
return back()->with($notification);
}
public function deleteFaqs(Request $request)
{
$request->validate([
'id' => 'required'
]);
Faq::destroy($request->id);
$notification = array('message' => 'FAQS Deleted Successfully.', 'alert-type' => 'success');
return back()->with($notification);
}
}