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.
77 lines
1.8 KiB
77 lines
1.8 KiB
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Service;
|
|
use App\Models\ServiceOld;
|
|
use App\Models\Faq;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class FaqController extends Controller
|
|
{
|
|
protected $view= 'admin.faq.';
|
|
protected $redirect = 'admin/faqs';
|
|
|
|
|
|
public function index(){
|
|
$settings = Faq::paginate(config('custom.per_page'));
|
|
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();
|
|
$setting = Faq::create($requestData);
|
|
Session::flash('success','FAQ is created');
|
|
return redirect($this->redirect);
|
|
|
|
}
|
|
|
|
public function edit($id){
|
|
$setting = Faq::findorfail($id);
|
|
$services = Service::all();
|
|
return view($this->view.'edit',compact('setting'),compact('services'));
|
|
}
|
|
|
|
public function update(Request $request, $id){
|
|
|
|
$setting =Faq::findorfail($id);
|
|
$this->validate(\request(), [
|
|
'question' =>'required|string',
|
|
'answer'=>'required',
|
|
'status' => 'required',
|
|
|
|
]);
|
|
|
|
$requestData = $request->all();
|
|
$setting->fill($requestData);
|
|
$setting->save();
|
|
Session::flash('success','FAQ is Updated');
|
|
return redirect($this->redirect);
|
|
|
|
}
|
|
public function show($id)
|
|
{
|
|
|
|
$faq = new Faq();
|
|
|
|
|
|
$setting = $faq->findorfail($id);
|
|
|
|
|
|
return view($this->view . 'show', compact('setting'));
|
|
}
|
|
}
|
|
|