You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.8 KiB
78 lines
1.8 KiB
2 years ago
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Admin;
|
||
|
|
||
|
use App\Http\Controllers\Controller;
|
||
|
use App\Models\Service;
|
||
|
use App\Models\ServiceOld;
|
||
2 years ago
|
use App\Models\Faq;
|
||
2 years ago
|
use Illuminate\Http\Request;
|
||
|
use Illuminate\Support\Facades\Session;
|
||
|
|
||
2 years ago
|
class FaqController extends Controller
|
||
2 years ago
|
{
|
||
2 years ago
|
protected $view= 'admin.faq.';
|
||
|
protected $redirect = 'admin/faqs';
|
||
2 years ago
|
|
||
|
|
||
|
public function index(){
|
||
2 years ago
|
$settings = Faq::paginate(config('custom.per_page'));
|
||
2 years ago
|
return view($this->view.'index',compact('settings'));
|
||
|
}
|
||
|
|
||
|
public function create(){
|
||
|
$settings = Service::get();
|
||
|
return view($this->view.'create',compact('settings'));
|
||
|
}
|
||
|
|
||
|
public function store(Request $request){
|
||
|
$this->validate(\request(), [
|
||
|
'question' =>'required|string',
|
||
|
'answer'=>'required',
|
||
|
'status' => 'required',
|
||
|
|
||
|
]);
|
||
|
|
||
|
$requestData = $request->all();
|
||
2 years ago
|
$setting = Faq::create($requestData);
|
||
|
Session::flash('success','FAQ is created');
|
||
2 years ago
|
return redirect($this->redirect);
|
||
|
|
||
|
}
|
||
|
|
||
|
public function edit($id){
|
||
2 years ago
|
$setting = Faq::findorfail($id);
|
||
2 years ago
|
$services = Service::all();
|
||
|
return view($this->view.'edit',compact('setting'),compact('services'));
|
||
|
}
|
||
|
|
||
|
public function update(Request $request, $id){
|
||
|
|
||
2 years ago
|
$setting =Faq::findorfail($id);
|
||
2 years ago
|
$this->validate(\request(), [
|
||
|
'question' =>'required|string',
|
||
|
'answer'=>'required',
|
||
|
'status' => 'required',
|
||
|
|
||
|
]);
|
||
|
|
||
|
$requestData = $request->all();
|
||
|
$setting->fill($requestData);
|
||
|
$setting->save();
|
||
2 years ago
|
Session::flash('success','FAQ is Updated');
|
||
2 years ago
|
return redirect($this->redirect);
|
||
|
|
||
|
}
|
||
2 years ago
|
public function show($id)
|
||
|
{
|
||
|
|
||
|
$faq = new Faq();
|
||
|
|
||
|
|
||
|
$setting = $faq->findorfail($id);
|
||
|
|
||
|
|
||
|
return view($this->view . 'show', compact('setting'));
|
||
|
}
|
||
2 years ago
|
}
|