Added all providers cache
Added all providers cache
This commit is contained in:
parent
693af83f6b
commit
a005fc4576
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||||
use App\Models\Providers;
|
use App\Models\Providers;
|
||||||
use DataTables;
|
use DataTables;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class ProvidersController extends Controller
|
class ProvidersController extends Controller
|
||||||
|
@ -30,6 +31,8 @@ class ProvidersController extends Controller
|
||||||
'name' => $request->provider_name
|
'name' => $request->provider_name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Cache::forget('all_providers');
|
||||||
|
|
||||||
return redirect()->route('providers.index')
|
return redirect()->route('providers.index')
|
||||||
->with('success', 'Provider Created Successfully.');
|
->with('success', 'Provider Created Successfully.');
|
||||||
}
|
}
|
||||||
|
@ -62,6 +65,8 @@ class ProvidersController extends Controller
|
||||||
|
|
||||||
$items->delete();
|
$items->delete();
|
||||||
|
|
||||||
|
Cache::forget('all_providers');
|
||||||
|
|
||||||
return redirect()->route('providers.index')
|
return redirect()->route('providers.index')
|
||||||
->with('success', 'Provider was deleted Successfully.');
|
->with('success', 'Provider was deleted Successfully.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\View\Components;
|
namespace App\View\Components;
|
||||||
|
|
||||||
use App\Models\Providers;
|
use App\Models\Providers;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\View\Component;
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
class ProvidersSelect extends Component
|
class ProvidersSelect extends Component
|
||||||
|
@ -15,8 +16,11 @@ class ProvidersSelect extends Component
|
||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
$all_providers = Cache::rememberForever('all_providers', function () {
|
||||||
|
return Providers::all();
|
||||||
|
});
|
||||||
return view('components.providers-select', [
|
return view('components.providers-select', [
|
||||||
'providers' => Providers::all()
|
'providers' => $all_providers
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user