formatting, juiste use voor UpdateDynamicRequest
This commit is contained in:
@@ -2,16 +2,14 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Dynamic;
|
||||
use App\Models\Ledger;
|
||||
use App\Models\Mutation;
|
||||
use App\Models\Message;
|
||||
use App\Models\ReadCursor;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Notifications\NewActivityNotification;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ActivityService
|
||||
{
|
||||
@@ -35,7 +33,7 @@ class ActivityService
|
||||
/**
|
||||
* Get the read cursor timestamp for a user on a specific entity.
|
||||
*/
|
||||
public function getCursorReadAt(User $user, $entity): \Carbon\CarbonInterface
|
||||
public function getCursorReadAt(User $user, $entity): CarbonInterface
|
||||
{
|
||||
$cursor = ReadCursor::where([
|
||||
'user_id' => $user->id,
|
||||
@@ -97,6 +95,7 @@ class ActivityService
|
||||
$participants = $dynamic->participants()->withPivot('display_name')->get();
|
||||
$participantsMap = $participants->reduce(function ($acc, $p) {
|
||||
$acc[$p->id] = $p->pivot->display_name ?? $p->name;
|
||||
|
||||
return $acc;
|
||||
}, []);
|
||||
|
||||
@@ -112,6 +111,7 @@ class ActivityService
|
||||
// Resolve <user:id> placeholders to actual names/display names
|
||||
$messageData['content'] = preg_replace_callback('/<user:(\d+)>/', function ($matches) use ($participantsMap) {
|
||||
$userId = $matches[1];
|
||||
|
||||
return $participantsMap[$userId] ?? "User #{$userId}";
|
||||
}, $message->content);
|
||||
|
||||
@@ -140,7 +140,7 @@ class ActivityService
|
||||
/**
|
||||
* Partition activities into read and unread, and construct the grouped entity metadata.
|
||||
*/
|
||||
private function partitionAndGroupActivities(array $activities, \Carbon\CarbonInterface $readAt, Dynamic $dynamic, array &$groupedDynamics): void
|
||||
private function partitionAndGroupActivities(array $activities, CarbonInterface $readAt, Dynamic $dynamic, array &$groupedDynamics): void
|
||||
{
|
||||
$alreadyRead = [];
|
||||
$unread = [];
|
||||
@@ -153,7 +153,7 @@ class ActivityService
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($unread)) {
|
||||
if (! empty($unread)) {
|
||||
$context = array_slice($alreadyRead, 0, 2);
|
||||
|
||||
$groupedDynamics[] = [
|
||||
@@ -192,4 +192,4 @@ class ActivityService
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user