PATH:
home
/
lab2454c
/
westernclear.net
/
app
/
Http
/
Controllers
/
Admin
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\FaqCategory; class FaqCategoryController extends Controller { /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('admin.faq.category.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $values = $request->validate([ "name"=>'required|string|max:255|unique:faq_categories,name', "short_description"=>'nullable|string|max:500', ]); $faqCategory = new FaqCategory(); $faqCategory->fill($values); $faqCategory->save(); $notify[] = ['success', 'Category is added!']; return redirect()->route('faq.index')->withNotify($notify); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(FaqCategory $faqCategory) { $data['faqCategory'] = $faqCategory; return view('admin.faq.category.edit', $data); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, FaqCategory $faqCategory) { $changed = false; $values = $request->validate([ "name"=>'required|string|max:255|unique:faq_categories,name,'. $faqCategory->id, "short_description"=>'nullable|string|max:500', ]); $faqCategory->fill($values); if ($faqCategory->isDirty()) { $faqCategory->save(); $changed = true; } if (! $changed) { $notify[] = ['warning', 'No changes done to save']; return redirect()->route('faq.index')->withNotify($notify); } $notify[] = ['success', 'Category is Updated!']; return redirect()->route('faq.index')->withNotify($notify); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(FaqCategory $faqCategory) { if ($faqCategory->status == 'active') { $faqCategory->status = 'inactive'; } else { $faqCategory->status = 'active'; } $faqCategory->save(); $notify[] = ['success', $faqCategory->name . ' ' . (($faqCategory->status == 'inactive') ? 'Disabled' : 'Enabled') . ' successfully!']; return redirect()->route('faq.index')->withNotify($notify); } }
[-] HomeBannerController.php
[edit]
[-] PasswordController.php
[edit]
[-] AdvisorController.php
[edit]
[+]
..
[-] SiteSettingController.php
[edit]
[-] PageController.php
[edit]
[-] FormController.php
[edit]
[-] SocialLinkController.php
[edit]
[-] EducationQuestionController.php
[edit]
[-] AdminUserController.php
[edit]
[+]
Home
[-] LeadershipController.php
[edit]
[-] FaqController.php
[edit]
[-] GalleryController.php
[edit]
[-] LoginController.php
[edit]
[-] InvitationCodeController.php
[edit]
[-] FormCategoryController.php
[edit]
[-] DashboardController.php
[edit]
[-] FaqCategoryController.php
[edit]
[-] InsightController.php
[edit]
[-] EducationCategoryController.php
[edit]