What is it about ?
Filtering the cache data using two approaches. Below is the code.
Attempt : 1
$Categories = \Cache::rememberForever('Categories', function() {
return \App\Models\Skill\Category_Model::all();
});
$Category = $Categories->where('CategoryID', $request->input('CategoryID'));
Attempt : 2
$Categories = \Cache::rememberForever('Categories', function() {
return \App\Models\Skill\Category_Model::all();
});
foreach($Categories as $Category) {
if($Category->CategoryID == $request->input('CategoryID')) {
$Category->Category = $request->input('Category');
$Category->IsActive = $request->input('IsActive') == "on" ? 1 : 0;
$Category->save();
\Cache::forget('Categories');
return Redirect('Categories-List');
}
}
Question:
While using Approach : 1, results are always null, where as while using Approach : 2, there is no Problem. Is there anything wrong ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire