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\EducationCategory; class EducationCategoryController extends Controller { /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('admin.education.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:education_categories,name', "short_description"=>'nullable|string|max:2000', ]); $educationCategory = new EducationCategory(); $educationCategory->fill($values); $educationCategory->save(); $notify[] = ['success', 'Category 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(EducationCategory $educationCategory) { $data['educationCategory'] = $educationCategory; return view('admin.education.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, EducationCategory $educationCategory) { $changed = false; $values = $request->validate([ "name"=>'required|string|max:255|unique:education_categories,name,'. $educationCategory->id, "short_description"=>'nullable|string|max:2000', ]); $educationCategory->fill($values); if ($educationCategory->isDirty()) { $educationCategory->save(); $changed = true; } if (! $changed) { $notify[] = ['warning', 'No changes done to save']; return redirect()->route('educationQuestion.index')->withNotify($notify); } $notify[] = ['success', 'Category 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(EducationCategory $educationCategory) { if ($educationCategory->status == 'active') { $educationCategory->status = 'inactive'; } else { $educationCategory->status = 'active'; } $educationCategory->save(); $notify[] = ['success', $educationCategory->name . ' ' . (($educationCategory->status == 'inactive') ? 'Disabled' : 'Enabled') . ' successfully!']; return redirect()->route('educationQuestion.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]