validate([ 'provider_name' => 'required|min:2' ]); Providers::create([ 'name' => $request->provider_name ]); Cache::forget('providers'); return redirect()->route('providers.index') ->with('success', 'Provider Created Successfully.'); } public function show(Providers $provider) { $data = Providers::showServicesForProvider($provider->id); return view('providers.show', compact(['provider', 'data'])); } public function destroy(Providers $provider) { $items = Providers::find($provider->id); $items->delete(); Cache::forget('providers'); return redirect()->route('providers.index') ->with('success', 'Provider was deleted Successfully.'); } public function getProviders(Request $request) { if ($request->ajax()) { $data = Providers::latest()->get(); $dt = Datatables::of($data) ->addIndexColumn() ->addColumn('action', function ($row) { $actionBtn = 'Edit Delete'; return $actionBtn; }) ->rawColumns(['action']) ->make(true); } } }