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\EducationQuestion; use App\Models\EducationCategory; use App\Models\EducationText; class EducationQuestionController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['educationQuestions'] = EducationQuestion::paginate('10'); $data['educationCategories'] = EducationCategory::all(); return view('admin.education.list', $data); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $data['categories'] = EducationCategory::where('status', 'active')->get(); return view('admin.education.create', $data); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $values = $request->validate([ "question"=>'required|string|max:255', "answer"=>'required|string|max:5000', "category"=>'required|integer|exists:education_categories,id', ]); //dd($values); $category = EducationCategory::find($values['category']); $educationQuestion = new EducationQuestion(); $educationQuestion->fill($values); $educationQuestion->category()->associate($category); $educationQuestion->save(); $notify[] = ['success', 'Education Question is added!']; return redirect()->route('educationQuestion.index')->withNotify($notify); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(EducationQuestion $educationQuestion) { $data['educationQuestion'] = $educationQuestion; $data['categories'] = EducationCategory::where('status', 'active')->get(); return view('admin.education.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, EducationQuestion $educationQuestion) { $changed = false; $values = $request->validate([ "question"=>'required|string|max:255', "answer"=>'required|string|max:5000', "category"=>'required|integer|exists:education_categories,id', ]); $educationQuestion->fill($values); if ($educationQuestion->isDirty()) { $educationQuestion->save(); $changed = true; } //Check for Category Cahnges $category = EducationCategory::find($values['category']); if ($category != $educationQuestion->category) { $educationQuestion->category()->associate($category); $educationQuestion->save(); $changed = true; } if (! $changed) { $notify[] = ['warning', 'No changes done to save']; return redirect()->route('educationQuestion.index')->withNotify($notify); } $notify[] = ['success', 'Education Question is Updated!']; return redirect()->route('educationQuestion.index')->withNotify($notify); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(EducationQuestion $educationQuestion) { if (isset($educationQuestion)) { $educationQuestion->delete(); } $notify[] = ['success', 'Education Question is Deleted!']; return redirect()->route('educationQuestion.index')->withNotify($notify); } public function textEdit() { $data['educationText'] = EducationText::first(); return view('admin.education.text.edit', $data); } public function textUpdate(Request $request) { $educationText = EducationText::first(); $changed = false; $values = $request->validate([ "content" => 'required|string|max:2000', ]); //dd($values); $educationText->fill($values); if ($educationText->isDirty()) { $educationText->save(); $changed = true; } if (! $changed) { $notify[] = ['warning', 'No changes done to save']; return redirect()->route('educationText.edit')->withNotify($notify); } $notify[] = ['success', 'Education Text is Updated!']; return redirect()->route('educationText.edit')->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]