Added all providers cache

Added all providers cache
This commit is contained in:
cp6 2022-03-03 14:39:51 +11:00
parent 693af83f6b
commit a005fc4576
2 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Providers;
use DataTables;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class ProvidersController extends Controller
@ -30,6 +31,8 @@ class ProvidersController extends Controller
'name' => $request->provider_name
]);
Cache::forget('all_providers');
return redirect()->route('providers.index')
->with('success', 'Provider Created Successfully.');
}
@ -62,6 +65,8 @@ class ProvidersController extends Controller
$items->delete();
Cache::forget('all_providers');
return redirect()->route('providers.index')
->with('success', 'Provider was deleted Successfully.');
}

View File

@ -3,6 +3,7 @@
namespace App\View\Components;
use App\Models\Providers;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\Component;
class ProvidersSelect extends Component
@ -15,8 +16,11 @@ class ProvidersSelect extends Component
*/
public function render()
{
$all_providers = Cache::rememberForever('all_providers', function () {
return Providers::all();
});
return view('components.providers-select', [
'providers' => Providers::all()
'providers' => $all_providers
]);
}
}