Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
myckhel committed Jun 18, 2021
1 parent f9e723d commit e868db5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Http/Controllers/ConversationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public function index(PaginableRequest $request)
$order = $request->order;
$orderBy = $request->orderBy;

$eventColumns = ['id', 'maker_id', 'made_type', 'made_id', 'created_at'];

$queryEvent = fn ($q) => $q->select($eventColumns)->notMessanger($user->id);

$conversations = $user->conversations()
->whereHasLastMessage($user)
->withCount([
Expand All @@ -30,9 +34,9 @@ public function index(PaginableRequest $request)
])
->orderByDesc('latest_message_at')
->with([
'delivery' => fn ($q) => $q->select('id', 'maker_id', 'made_type', 'made_id', 'created_at')->notMessanger($user->id)->where('maker_id', '!=', $user->id),
'read' => fn ($q) => $q->select('id', 'maker_id', 'made_type', 'made_id', 'created_at')->notMessanger($user->id)->where('maker_id', '!=', $user->id),
'trashed' => fn ($q) => $q->select('id', 'maker_id', 'made_type', 'made_id', 'created_at')->whereMakerId($user->id),
'delivery' => fn ($q) => $queryEvent($q)->where('maker_id', '!=', $user->id),
'read' => fn ($q) => $queryEvent($q)->where('maker_id', '!=', $user->id),
'trashed' => $queryEvent,
'last_message' => fn ($q) => $q->select(['id','user_id','message','conversation_id', 'created_at'])
->with([
// 'latestMedia' => fn ($q) => $q->select('id', 'model_type', 'model_id', 'name'),
Expand Down

0 comments on commit e868db5

Please sign in to comment.