Added all locations cache
Added all locations cache
This commit is contained in:
parent
a005fc4576
commit
92bc68401a
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Locations;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
|
@ -30,6 +31,8 @@ class LocationsController extends Controller
|
|||
'name' => $request->location_name
|
||||
]);
|
||||
|
||||
Cache::forget('all_locations');
|
||||
|
||||
return redirect()->route('locations.index')
|
||||
->with('success', 'Location Created Successfully.');
|
||||
}
|
||||
|
@ -62,6 +65,8 @@ class LocationsController extends Controller
|
|||
|
||||
$items->delete();
|
||||
|
||||
Cache::forget('all_locations');
|
||||
|
||||
return redirect()->route('locations.index')
|
||||
->with('success', 'Location was deleted Successfully.');
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\View\Components;
|
||||
|
||||
use App\Models\Locations;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class LocationsSelect extends Component
|
||||
|
@ -14,8 +15,11 @@ class LocationsSelect extends Component
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
$all_locations = Cache::rememberForever('all_locations', function () {
|
||||
return Locations::all();
|
||||
});
|
||||
return view('components.locations-select', [
|
||||
'locations' => Locations::all()
|
||||
'locations' => $all_locations
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user