Files
ntspi-app/app/Containers/Main/Tasks/GetUpcomingEventsTask.php
T
F4ilji 2d101dcdda feat: Refactor MainController and related tasks to follow Porto architecture
- Moved logic from MainController to dedicated action and task classes.
- Introduced GetMainPageDataAction, GetEducationsDataTask, GetRecentPostsTask, GetUpcomingEventsTask, and GetPageDataTask for better separation of concerns.
- Updated routes to use the new MainController from the Main container.
- Deprecated the old MainController with a clear message for future removal.
- Updated caching mechanisms to use the new task classes.
- Adjusted environment variable access to use config() instead of env() for better practice.
- Added new MainPageResource for structured data response.
- Updated .gitignore to exclude QWEN.md.
- Added Jenkins service to docker-compose for CI/CD integration.
2025-12-16 12:20:01 +05:00

31 lines
892 B
PHP

<?php
namespace App\Containers\Main\Tasks;
use App\Containers\Event\Models\Event;
use App\Containers\Event\UI\WEB\Transformers\EventThumbnailResource;
use DateTime;
use Illuminate\Support\Facades\Cache;
class GetUpcomingEventsTask
{
public function run()
{
return Cache::remember('upcoming_events', now()->addHour(), function () {
return $this->getUpcomingEvents();
});
}
private function getUpcomingEvents()
{
$event_date_start = (new DateTime())->format('Y-m-d');
return EventThumbnailResource::collection(
Event::select('title', 'slug', 'event_date_start', 'event_time_start' , 'address', 'is_online', 'category_id')
->where('event_date_start', '>=', $event_date_start)
->orderBy('event_date_start', 'asc')
->limit(3)
->get()
);
}
}