middleware('auth'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $page = "Contact List"; $ContactList = Contact::orderBy('id', 'DESC')->get(); return view("admin.contact.index", compact('ContactList','page')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $page = "View Contact Detail"; $Contact = Contact::find($id); if($Contact){ return view('admin.contact.view', compact('Contact','page')); } else{ return Redirect::back()->with("danger","Something went wrong please try again"); } } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $Contact = Contact::find($id); $this->validate($request, [ 'c_name' => 'required', ], [ 'c_name.required' => 'Breed Name is required field.', ]); $this->validate($request, [ 'c_image.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048', ]); $Contact->c_name = $request->c_name; if(!empty($request->file('c_image'))){ $image = $request->file('c_image'); $ext = strtoupper($image->getClientOriginalExtension()); if($ext == "JPG" || $ext == "JPEG" || $ext == "PNG" || $ext == "GIF"){ $ContactData = Contact::find($id);; $filename = public_path('/uploads/ContactImage/'.$ContactData->c_image); if(file_exists($filename) && !empty($ContactData->c_image)){ unlink($filename); } $input['c_image'] = time().'-Contact.'.$image->getClientOriginalExtension(); $destinationPath = public_path('/uploads/ContactImage'); $image->move($destinationPath, $input['c_image']); $Contact->c_image = $input['c_image']; } else{ return Redirect::back()->with("danger","Please select jpg, png, gif only"); } } $Contact->save(); return Redirect::to("admin/Contact")->with("success","Contact updated successfully"); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $result = Contact::deleteData($id); if($result){ return Redirect::back()->with("success","Contact deleted successfully"); } else{ return Redirect::back()->with("danger","Something went wrong please try again"); } } public function contactDelete(Request $request) { $ids = $request->ids; Contact::whereIn('id',explode(",",$ids))->forceDelete(); return response()->json(['status'=>'success','message'=>"Contact deleted successfully."]); } public function export_Contact(Request $request) { return Excel::download(new ContactExport($request->bulkExcelData), 'contactData.xlsx'); } }