get(); return view('admin.education_level.index',$data); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $data['title'] = "Education Level Create"; return view('admin.education_level.add',$data); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request,[ 'level_name' => 'required' ]); $user_id = \Auth::user()->id; $edu_level = new EducationLevel; $edu_level->level_name = $request->level_name; $edu_level->added_by = $user_id; $edu_level->status = 1; $edu_level->save(); return redirect()->back()->with('msg','Data Insert Successful!'); } public function edit($id) { $data['title'] = "Education Level Edit"; $data['edu_level'] = EducationLevel::find($id); return view('admin.education_level.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, $id) { $this->validate($request,[ 'level_name' => 'required' ]); $user_id = \Auth::user()->id; $edu_level = EducationLevel::find($id); $edu_level->level_name = $request->level_name; $edu_level->updated_by = $user_id; $edu_level->save(); return redirect('admin/education_level')->with('msg','Data Update Successful!'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { EducationLevel::whereId($id)->delete(); return redirect('admin/education_level')->with('msg','Successfully Deleted!'); } public function statusUpdate($id) { $edu_info = EducationLevel::find($id); if($edu_info->status == 0){ $edu_info->status = 1; $status = 'published'; }else{ $edu_info->status = 0; $status = 'unpublished'; } $user_id = \Auth::user()->id; $edu_info->approved_by = $user_id; $edu_info->update(); } }