Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
myckhel committed Oct 16, 2021
1 parent 7ffc3ec commit 733170a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
12 changes: 2 additions & 10 deletions src/Http/Controllers/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ class MessageController extends Controller
public function index(PaginableRequest $request)
{
$request->validate([
'orderBy' => '',
'search' => 'min:3',
'order' => 'in:asc,desc',
'pageSize' => 'int',
'conversation_id' => 'int|nullable',
'other_user_id' => 'int',
'system' => 'boolean',
'reply_id' => 'int',
'reply_type' => [
Rule::requiredIf(fn () => $request->reply_id),
Expand All @@ -36,11 +32,8 @@ public function index(PaginableRequest $request)

$user = $request->user();
$pageSize = $request->pageSize;
$order = $request->order;
$orderBy = $request->orderBy;
$reply_type = $request->reply_type;
$reply_id = $request->reply_id;
$system = $request->system;
$reply = [];
$with = [
'reply',
Expand All @@ -55,7 +48,6 @@ public function index(PaginableRequest $request)
$reply['reply_type'] = $reply_type;
}


$messages = $user->messages($request->conversation_id, $request->other_user_id, $reply ?? null)
// ->withUrls(['image', 'videos'])
->whereConversationWasntDeleted($user)
Expand Down Expand Up @@ -87,8 +79,8 @@ public function store(Request $request)
@[
'reply_id' => $reply_id,
'reply_type' => $reply_type,
'image' => $image,
'videos' => $videos,
// 'image' => $image,
// 'videos' => $videos,
'token' => $token,
'other_user_id' => $other_user_id,
'type' => $type,
Expand Down
15 changes: 6 additions & 9 deletions src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,12 @@ function makeDelivered($user = null){
}

private function makeChatEvent(ChatEventMaker $user, $type = 'read', $all = false) {
$create = [];
$this->map(function ($msg) use(&$create, $all, $user) {
$create[] = [
'made_id' => $msg->id,
'made_type' => $msg::class,
'type' => 'delete',
'all' => $all ? $msg->user_id === $user->id : false,
];
});
$create = $this->map(fn ($msg) => [
'made_id' => $msg->id,
'made_type' => $msg::class,
'type' => 'delete',
'all' => $all ? $msg->user_id === $user->id : false,
]);

return $user->chatEventMakers()->createMany($create);
}
Expand Down

0 comments on commit 733170a

Please sign in to comment.