Enhance chat functionality: add support for vendor-specific chat channels, implement methods for managing conversations with admin and store owners, and improve conversation payload structure. Update middleware and policies for better access control, and refine chat UI to indicate view-only status for store owner replies.
This commit is contained in:
1 parent
c55694ec8c
commit
5c17c35741
23 files changed
+729
-59
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Chat\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ChatChannelTargetResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'image' => $this->thumbnail('200x200'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,18 @@ public function toArray(Request $request): array
|
||||
? $this->users->firstWhere('id', '!=', $request->user()?->id)
|
||||
: null;
|
||||
|
||||
$channel = $this->relationLoaded('channel') ? $this->channel : null;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'thread_key' => $this->thread_key,
|
||||
'user' => $this->when($otherUser, fn () => new ChatUserResource($otherUser)),
|
||||
'channel' => $channel ? [
|
||||
'id' => $channel->id,
|
||||
'name' => $channel->name,
|
||||
'slug' => $channel->slug,
|
||||
'image' => $channel->thumbnail('200x200'),
|
||||
] : null,
|
||||
'last_message' => $this->when(
|
||||
$this->relationLoaded('latestMessage') && $this->latestMessage,
|
||||
fn () => new MessageResource($this->latestMessage)
|
||||
|
||||
Reference in new issue
Block a user