mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 23:42:32 +01:00
Added all labels cache
Added all labels cache
This commit is contained in:
parent
92bc68401a
commit
01cf83a31c
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Labels;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -32,6 +33,8 @@ class LabelsController extends Controller
|
||||
'label' => $request->label
|
||||
]);
|
||||
|
||||
Cache::forget('all_labels');
|
||||
|
||||
return redirect()->route('labels.index')
|
||||
->with('success', 'Label Created Successfully.');
|
||||
}
|
||||
@ -65,6 +68,8 @@ class LabelsController extends Controller
|
||||
|
||||
Labels::deleteLabelAssignedAs($label_id);
|
||||
|
||||
Cache::forget('all_labels');
|
||||
|
||||
return redirect()->route('labels.index')
|
||||
->with('success', 'Label was deleted Successfully.');
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Models\Labels;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class LabelsSelect extends Component
|
||||
@ -14,8 +15,11 @@ class LabelsSelect extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$all_labels = Cache::rememberForever('all_labels', function () {
|
||||
return Labels::all();
|
||||
});
|
||||
return view('components.labels-select', [
|
||||
'labels' => Labels::all()
|
||||
'labels' => $all_labels
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user