A new Notifications module shows a bell beside the profile menu with the number of unseen notifications and a panel of the last 7 days; opening it marks them seen, and each notification links to its job or task. - A daily run at 14.00 (notifications:task-starts) tells the assignee and members of tasks that start by the next working day, skipping holidays and days off, done tasks and archived jobs. - Jobs publishes PeopleAddedToTask and PeopleAddedToJob when someone else makes a user a task's assignee or member or gives them a role on a job; those users are notified at once. UpdateTask and ScheduleTask now take the acting user. - A notification link to #task-<id> opens that task card on the job page. Also: simplifying job fields per service unit (K31) moves to the end of phase 4, and the workflow template browser test waits for Livewire's progress bar before its last accessibility check. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Notifications\Infrastructure\Persistence\Repositories;
|
|
|
|
use App\Modules\Notifications\Application\Contracts\NotificationQueries;
|
|
use App\Modules\Notifications\Application\DTOs\NotificationSummary;
|
|
use App\Modules\Notifications\Infrastructure\Persistence\Eloquent\NotificationModel;
|
|
use DateTimeImmutable;
|
|
|
|
class EloquentNotificationQueries implements NotificationQueries
|
|
{
|
|
public function recentFor(int $userId, DateTimeImmutable $since): array
|
|
{
|
|
return NotificationModel::query()
|
|
->where('user_id', $userId)
|
|
->where('created_at', '>=', $since)
|
|
->orderByDesc('created_at')
|
|
->orderByDesc('id')
|
|
->get()
|
|
->map(fn (NotificationModel $model): NotificationSummary => new NotificationSummary(
|
|
$model->id,
|
|
$model->type,
|
|
$model->params,
|
|
$model->created_at->setTimezone((string) config('app.business_timezone'))->format('Y-m-d H:i'),
|
|
$model->seen_at !== null,
|
|
))
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
public function unseenCount(int $userId, DateTimeImmutable $since): int
|
|
{
|
|
return NotificationModel::query()
|
|
->where('user_id', $userId)
|
|
->where('created_at', '>=', $since)
|
|
->whereNull('seen_at')
|
|
->count();
|
|
}
|
|
}
|