refactor multiple widget controllers; replace caching logic with action classes for data retrieval, enhancing code clarity and maintainability

This commit is contained in:
F4ilji
2025-07-22 18:22:04 +05:00
parent 7a8a6e023d
commit 528a4b24b0
19 changed files with 320 additions and 110 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Containers\Widget\Tasks;
use App\Containers\AppStructure\Models\Page;
use Illuminate\Support\Facades\Cache;
class FindPageByIdTask
{
public function run(int $id)
{
$cacheKey = 'page_' . md5($id);
return Cache::remember($cacheKey, now()->addHours(1), function () use ($id) {
return Page::where('id', '=', $id)
->with('section.pages.section', 'section.mainSection')
->firstOrFail();
});
}
}