Refactor chat functionality: remove ChatController, enhance MessageSent event with broadcasting capabilities, and update Conversation and Message models for improved relationships. Update API routes for chat operations and adjust CORS settings for broadcasting authentication.
This commit is contained in:
1 parent
b52b567388
commit
ccfffe6173
23 files changed
+425
-198
No files matched your search
@@ -18,6 +18,7 @@ DB_DATABASE=postshop
|
|||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
# Use `pusher` (Pusher Cloud or Soketi) for live chat. `log` is fine locally without websockets.
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
FILESYSTEM_DISK=local
|
FILESYSTEM_DISK=local
|
||||||
@@ -46,6 +47,7 @@ AWS_DEFAULT_REGION=us-east-1
|
|||||||
AWS_BUCKET=
|
AWS_BUCKET=
|
||||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
# Required when BROADCAST_DRIVER=pusher (Pusher Cloud, or Soketi using the pusher driver)
|
||||||
PUSHER_APP_ID=
|
PUSHER_APP_ID=
|
||||||
PUSHER_APP_KEY=
|
PUSHER_APP_KEY=
|
||||||
PUSHER_APP_SECRET=
|
PUSHER_APP_SECRET=
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Events\Conversation;
|
namespace App\Events\Conversation;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Resources\MessageResource;
|
||||||
|
use App\Models\Chat\Message;
|
||||||
use Illuminate\Broadcasting\Channel;
|
use Illuminate\Broadcasting\Channel;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
use Illuminate\Broadcasting\PrivateChannel;
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
@@ -13,14 +15,12 @@ class MessageSent implements ShouldBroadcast
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
public $message;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*/
|
*/
|
||||||
public function __construct($message)
|
public function __construct(private Message $message)
|
||||||
{
|
{
|
||||||
$this->message = $message->load('user');
|
$this->message->loadMissing('user');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,4 +34,17 @@ public function broadcastOn(): array
|
|||||||
new PrivateChannel('chat.'.$this->message->conversation_id),
|
new PrivateChannel('chat.'.$this->message->conversation_id),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function broadcastAs(): string
|
||||||
|
{
|
||||||
|
return 'message.sent';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function broadcastWith(): array
|
||||||
|
{
|
||||||
|
return (new MessageResource($this->message->loadMissing('user')))->resolve();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat;
|
||||||
|
|
||||||
|
use App\Events\Conversation\MessageSent;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Requests\ChatContactsRequest;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Requests\ChatMessagesRequest;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Requests\ChatSendMessageRequest;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Requests\ChatStartRequest;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Resources\ChatUserResource;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Resources\ConversationResource;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\Resources\MessageResource;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Chat\Conversation;
|
||||||
|
use App\Models\Chat\Message;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class ChatController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* (*) Chat conversations (inbox)
|
||||||
|
*/
|
||||||
|
public function conversations(): JsonResponse
|
||||||
|
{
|
||||||
|
$conversations = auth()->user()
|
||||||
|
->conversations()
|
||||||
|
->with(['users', 'latestMessage.user'])
|
||||||
|
->withCount([
|
||||||
|
'messages as unread_count' => fn ($query) => $query
|
||||||
|
->where('user_id', '!=', auth()->id())
|
||||||
|
->whereNull('seen_at'),
|
||||||
|
])
|
||||||
|
->withMax('messages', 'created_at')
|
||||||
|
->orderByDesc('messages_max_created_at')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return response()->rest(ConversationResource::collection($conversations));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (*) Searchable chat contacts
|
||||||
|
*/
|
||||||
|
public function contacts(ChatContactsRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$paginator = User::query()
|
||||||
|
->select(['id', 'first_name', 'last_name'])
|
||||||
|
->where('id', '!=', $request->user()->id)
|
||||||
|
->when($request->q, function ($query, $search) {
|
||||||
|
$query->where(function ($query) use ($search) {
|
||||||
|
$query->where('first_name', 'like', '%'.$search.'%')
|
||||||
|
->orWhere('last_name', 'like', '%'.$search.'%')
|
||||||
|
->orWhere('phone_number', 'like', '%'.$search.'%');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('first_name')
|
||||||
|
->simplePaginate($request->perPage);
|
||||||
|
|
||||||
|
$paginator->through(fn (User $user) => (new ChatUserResource($user))->resolve());
|
||||||
|
|
||||||
|
return response()->rest_paginate($paginator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (*) Find or create a 1:1 conversation
|
||||||
|
*/
|
||||||
|
public function start(ChatStartRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$conversation = Conversation::findOrCreateOneToOne(
|
||||||
|
$request->user()->id,
|
||||||
|
$request->integer('user_id')
|
||||||
|
);
|
||||||
|
|
||||||
|
$conversation->load(['users', 'latestMessage.user'])
|
||||||
|
->loadCount([
|
||||||
|
'messages as unread_count' => fn ($query) => $query
|
||||||
|
->where('user_id', '!=', $request->user()->id)
|
||||||
|
->whereNull('seen_at'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->rest(new ConversationResource($conversation));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (*) Conversation messages
|
||||||
|
*/
|
||||||
|
public function messages(ChatMessagesRequest $request, Conversation $conversation): JsonResponse
|
||||||
|
{
|
||||||
|
abort_unless($conversation->hasParticipant($request->user()), 403);
|
||||||
|
|
||||||
|
$paginator = $conversation->messages()
|
||||||
|
->with('user')
|
||||||
|
->latest()
|
||||||
|
->simplePaginate($request->perPage);
|
||||||
|
|
||||||
|
$paginator->through(fn (Message $message) => (new MessageResource($message))->resolve());
|
||||||
|
|
||||||
|
return response()->rest_paginate($paginator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (*) Send a message
|
||||||
|
*/
|
||||||
|
public function send(ChatSendMessageRequest $request, Conversation $conversation): JsonResponse
|
||||||
|
{
|
||||||
|
abort_unless($conversation->hasParticipant($request->user()), 403);
|
||||||
|
|
||||||
|
$message = $conversation->messages()->create([
|
||||||
|
'user_id' => $request->user()->id,
|
||||||
|
'body' => $request->validated('body'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$message->load('user');
|
||||||
|
|
||||||
|
broadcast(new MessageSent($message))->toOthers();
|
||||||
|
|
||||||
|
return response()->rest(new MessageResource($message), 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (*) Mark the other user's messages as seen
|
||||||
|
*/
|
||||||
|
public function read(Conversation $conversation): JsonResponse
|
||||||
|
{
|
||||||
|
abort_unless($conversation->hasParticipant(auth()->user()), 403);
|
||||||
|
|
||||||
|
$conversation->messages()
|
||||||
|
->where('user_id', '!=', auth()->id())
|
||||||
|
->whereNull('seen_at')
|
||||||
|
->update(['seen_at' => now()]);
|
||||||
|
|
||||||
|
return response()->rest();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ChatContactsRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'q' => ['nullable', 'string', 'max:100'],
|
||||||
|
'perPage' => ['nullable', 'integer', 'min:1', 'max:50'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function passedValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'perPage' => $this->perPage ?: 20,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ChatMessagesRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'perPage' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function passedValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'perPage' => $this->perPage ?: 50,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ChatSendMessageRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'body' => ['required', 'string', 'max:5000'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class ChatStartRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'user_id' => ['required', 'integer', 'exists:users,id', Rule::notIn([$this->user()->id])],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ChatUserResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->fullname,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ConversationResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
$otherUser = $this->relationLoaded('users')
|
||||||
|
? $this->users->firstWhere('id', '!=', $request->user()?->id)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'user' => $this->when($otherUser, fn () => new ChatUserResource($otherUser)),
|
||||||
|
'last_message' => $this->when(
|
||||||
|
$this->relationLoaded('latestMessage') && $this->latestMessage,
|
||||||
|
fn () => new MessageResource($this->latestMessage)
|
||||||
|
),
|
||||||
|
'unread_count' => (int) ($this->unread_count ?? 0),
|
||||||
|
'created_at' => $this->created_at,
|
||||||
|
'updated_at' => $this->updated_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1\Chat\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class MessageResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'conversation_id' => $this->conversation_id,
|
||||||
|
'body' => $this->body,
|
||||||
|
'seen_at' => $this->seen_at,
|
||||||
|
'user' => new ChatUserResource($this->whenLoaded('user')),
|
||||||
|
'created_at' => $this->created_at,
|
||||||
|
'updated_at' => $this->updated_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use App\Events\Conversation\MessageSent;
|
|
||||||
use App\Models\Chat\Conversation;
|
|
||||||
use App\Models\Chat\Message;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ChatController extends Controller
|
|
||||||
{
|
|
||||||
public function contacts()
|
|
||||||
{
|
|
||||||
return User::select(['id', 'first_name', 'last_name'])
|
|
||||||
->get()
|
|
||||||
->map(function ($user) {
|
|
||||||
return [
|
|
||||||
'id' => $user->id,
|
|
||||||
'name' => $user->first_name.' '.$user->last_name,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function start(Request $request)
|
|
||||||
{
|
|
||||||
$user1 = auth()->id();
|
|
||||||
$user2 = $request->user_id;
|
|
||||||
|
|
||||||
$conversation = Conversation::whereHas('users', fn ($q) => $q->where('user_id', $user1))
|
|
||||||
->whereHas('users', fn ($q) => $q->where('user_id', $user2))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (! $conversation) {
|
|
||||||
$conversation = Conversation::create();
|
|
||||||
$conversation->users()->attach([$user1, $user2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $conversation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages($id)
|
|
||||||
{
|
|
||||||
return Message::with('user')
|
|
||||||
->where('conversation_id', $id)
|
|
||||||
->latest()
|
|
||||||
->take(50)
|
|
||||||
->get()
|
|
||||||
->reverse()
|
|
||||||
->values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function send(Request $request)
|
|
||||||
{
|
|
||||||
$message = Message::create([
|
|
||||||
'conversation_id' => $request->conversation_id,
|
|
||||||
'user_id' => auth()->id(),
|
|
||||||
'body' => $request->body,
|
|
||||||
]);
|
|
||||||
|
|
||||||
broadcast(new MessageSent($message))->toOthers();
|
|
||||||
|
|
||||||
return $message->load('user');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,18 +5,52 @@
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
class Conversation extends Model
|
class Conversation extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
public function users()
|
/**
|
||||||
|
* Find or create a 1:1 conversation between two users.
|
||||||
|
*/
|
||||||
|
public static function findOrCreateOneToOne(int $userId, int $otherUserId): self
|
||||||
|
{
|
||||||
|
$conversation = static::query()
|
||||||
|
->whereHas('users', fn ($query) => $query->where('users.id', $userId))
|
||||||
|
->whereHas('users', fn ($query) => $query->where('users.id', $otherUserId))
|
||||||
|
->has('users', '=', 2)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($conversation) {
|
||||||
|
return $conversation;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conversation = static::create();
|
||||||
|
$conversation->users()->attach([$userId, $otherUserId]);
|
||||||
|
|
||||||
|
return $conversation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function users(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(User::class);
|
return $this->belongsToMany(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages()
|
public function messages(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Message::class);
|
return $this->hasMany(Message::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function latestMessage(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Message::class)->latestOfMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasParticipant(User $user): bool
|
||||||
|
{
|
||||||
|
return $this->users()->where('users.id', $user->id)->exists();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,35 @@
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
class Message extends Model
|
class Message extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
public function user()
|
/**
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'conversation_id',
|
||||||
|
'user_id',
|
||||||
|
'body',
|
||||||
|
'seen_at',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'seen_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function conversation(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Conversation::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Chat\Conversation;
|
||||||
use App\Models\Concerns\HasEcommerceChannels;
|
use App\Models\Concerns\HasEcommerceChannels;
|
||||||
use App\Models\Concerns\HasSchemalessAttributes;
|
use App\Models\Concerns\HasSchemalessAttributes;
|
||||||
use App\Models\Concerns\InteractsWithNova;
|
use App\Models\Concerns\InteractsWithNova;
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
use App\Repositories\System\Cache\CacheRepository;
|
use App\Repositories\System\Cache\CacheRepository;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
@@ -112,6 +114,14 @@ public function addresses(): HasMany
|
|||||||
return $this->hasMany(UserAddress::class);
|
return $this->hasMany(UserAddress::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chat conversations
|
||||||
|
*/
|
||||||
|
public function conversations(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Conversation::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User's carts
|
* User's carts
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class BroadcastServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Broadcast::routes();
|
Broadcast::routes(['middleware' => ['auth:sanctum']]);
|
||||||
|
|
||||||
require base_path('routes/channels.php');
|
require base_path('routes/channels.php');
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
'paths' => ['api/*', 'sanctum/csrf-cookie', 'broadcasting/auth'],
|
||||||
|
|
||||||
'allowed_methods' => ['*'],
|
'allowed_methods' => ['*'],
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use BasementChat\Basement\Enums\MessageType;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::create('private_messages', static function (Blueprint $table): void {
|
|
||||||
/** @var string $model */
|
|
||||||
$model = config('basement.user_model');
|
|
||||||
/** @var Model $user */
|
|
||||||
$user = app($model);
|
|
||||||
|
|
||||||
$primaryKey = $user->getKeyName();
|
|
||||||
$tableName = $user->getTable();
|
|
||||||
|
|
||||||
$table->id();
|
|
||||||
$table->unsignedBigInteger('receiver_id');
|
|
||||||
$table->unsignedBigInteger('sender_id');
|
|
||||||
$table->foreign('receiver_id')->references($primaryKey)->on($tableName);
|
|
||||||
$table->foreign('sender_id')->references($primaryKey)->on($tableName);
|
|
||||||
$table->enum('type', [MessageType::document()->value, MessageType::text()->value]);
|
|
||||||
$table->string('value');
|
|
||||||
$table->timestamp('read_at')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
$table->softDeletes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('private_messages');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('private_messages');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Basement Chat leftovers are not restored.
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/*
|
|
||||||
! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com
|
|
||||||
*/.basement *,.basement :after,.basement :before{border:0 solid #e5e7eb;box-sizing:border-box}.basement :after,.basement :before{--tw-content:""}.basement{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:Nunito,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;line-height:inherit;margin:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4}.basement hr{border-top-width:1px;color:inherit;height:0}.basement abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.basement h1,.basement h2,.basement h3,.basement h4,.basement h5,.basement h6{font-size:inherit;font-weight:inherit}.basement a{color:inherit;text-decoration:inherit}.basement b,.basement strong{font-weight:bolder}.basement code,.basement kbd,.basement pre,.basement samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.basement small{font-size:80%}.basement sub,.basement sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.basement sub{bottom:-.25em}.basement sup{top:-.5em}.basement table{border-collapse:collapse;border-color:inherit;text-indent:0}.basement button,.basement input,.basement optgroup,.basement select,.basement textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}.basement button,.basement select{text-transform:none}.basement [type=button],.basement [type=reset],.basement [type=submit],.basement button{-webkit-appearance:button;background-color:transparent;background-image:none}.basement :-moz-focusring{outline:auto}.basement :-moz-ui-invalid{box-shadow:none}.basement progress{vertical-align:baseline}.basement ::-webkit-inner-spin-button,.basement ::-webkit-outer-spin-button{height:auto}.basement [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.basement ::-webkit-search-decoration{-webkit-appearance:none}.basement ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.basement summary{display:list-item}.basement blockquote,.basement dd,.basement dl,.basement figure,.basement h1,.basement h2,.basement h3,.basement h4,.basement h5,.basement h6,.basement hr,.basement p,.basement pre{margin:0}.basement fieldset{margin:0;padding:0}.basement legend{padding:0}.basement menu,.basement ol,.basement ul{list-style:none;margin:0;padding:0}.basement textarea{resize:vertical}.basement input::-moz-placeholder,.basement textarea::-moz-placeholder{color:#9ca3af;opacity:1}.basement input::placeholder,.basement textarea::placeholder{color:#9ca3af;opacity:1}.basement [role=button],.basement button{cursor:pointer}.basement :disabled{cursor:default}.basement audio,.basement canvas,.basement embed,.basement iframe,.basement img,.basement object,.basement svg,.basement video{display:block;vertical-align:middle}.basement img,.basement video{height:auto;max-width:100%}.basement [hidden]{display:none}.basement *,.basement :after,.basement :before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.basement ::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur:Line truncated
|
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";var t,e,n,r,i=!1,o=!1,a=[],s=-1;function u(t){!function(t){a.includes(t)||a.push(t);o||i||(i=!0,queueMicrotask(l))}(t)}function c(t){let e=a.indexOf(t);-1!==e&&e>s&&a.splice(e,1)}function l(){i=!1,o=!0;for(let t=0;t<a.length;t++)a[t](),s=t;a.length=0,s=-1,o=!1}var f=!0;function h(t){e=t}var d=[],p=[],v=[];function g(t,e){"function"==typeof e?(t._x_cleanups||(t._x_cleanups=[]),t._x_cleanups.push(e)):(e=t,p.push(e))}function y(t,e){t._x_attributeCleanups&&Object.entries(t._x_attributeCleanups).forEach((([n,r])=>{(void 0===e||e.includes(n))&&(r.forEach((t=>t())),delete t._x_attributeCleanups[n])}))}var m=new MutationObserver(T),b=!1;function w(){m.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),b=!0}function _(){(x=x.concat(m.takeRecords())).length&&!E&&(E=!0,queueMicrotask((()=>{T(x),x.length=0,E=!1}))),m.disconnect(),b=!1}var x=[],E=!1;function S(t){if(!b)return t();_();let e=t();return w(),e}var O=!1,k=[];function T(t){if(O)return void(k=k.concat(t));let e=[],n=[],r=new Map,i=new Map;for(let o=0;o<t.length;o++)if(!t[o].target._x_ignoreMutationObserver&&("childList"===t[o].type&&(t[o].addedNodes.forEach((t=>1===t.nodeType&&e.push(t))),t[o].removedNodes.forEach((t=>1===t.nodeType&&n.push(t)))),"attributes"===t[o].type)){let e=t[o].target,n=t[o].attributeName,a=t[o].oldValue,s=()=>{r.has(e)||r.set(e,[]),r.get(e).push({name:n,value:e.getAttribute(n)})},u=()=>{i.has(e)||i.set(e,[]),i.get(e).push(n)};e.hasAttribute(n)&&null===a?s():e.hasAttribute(n)?(u(),s()):u()}i.forEach(((t,e)=>{y(e,t)})),r.forEach(((t,e)=>{d.forEach((n=>n(e,t)))}));for(let t of n)if(!e.includes(t)&&(p.forEach((e=>e(t))),t._x_cleanups))for(;t._x_cleanups.length;)t._x_cleanups.pop()();e.forEach((t=>{t._x_ignoreSelf=!0,t._x_ignore=!0}));for(let t of e)n.includes(t)||t.isConnected&&(delete t._x_ignoreSelf,delete t._x_ignore,v.forEach((e=>e(t))),t._x_ignore=!0,t._x_ignoreSelf=!0);e.forEach((t=>{delete t._x_ignoreSelf,delete t._x_ignore})),e=null,n=null,r=null,i=null}function P(t){return j(A(t))}function C(t,e,n){return t._x_dataStack=[e,...A(n||t)],()=>{t._x_dataStack=t._x_dataStack.filter((t=>t!==e))}}function A(t){return t._x_dataStack?t._x_dataStack:"function"==typeof ShadowRoot&&t instanceof ShadowRoot?A(t.host):t.parentNode?A(t.parentNode):[]}function j(t){let e=new Proxy({},{ownKeys:()=>Array.from(new Set(t.flatMap((t=>Object.keys(t))))),has:(e,n)=>t.some((t=>t.hasOwnProperty(n))),get:(n,r)=>(t.find((t=>{if(t.hasOwnProperty(r)){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get&&n.get._x_alreadyBound||n.set&&n.set._x_alreadyBound)return!0;if((n.get||n.set)&&n.enumerable){let i=n.get,o=n.set,a=n;i=i&&i.bind(e),o=o&&o.bind(e),i&&(i._x_alreadyBound=!0),o&&(o._x_alreadyBound=!0),Object.defineProperty(t,r,{...a,get:i,set:o})}return!0}return!1}))||{})[r],set:(e,n,r)=>{let i=t.find((t=>t.hasOwnProperty(n)));return i?i[n]=r:t[t.length-1][n]=r,!0}});return e}function N(t){let e=(n,r="")=>{Object.entries(Object.getOwnPropertyDescriptors(n)).forEach((([i,{value:o,enumerable:a}])=>{if(!1===a||void 0===o)return;let s=""===r?i:`${r}.${i}`;var u;"object"==typeof o&&null!==o&&o._x_interceptor?n[i]=o.initialize(t,s,i):"object"!=typeof(u=o)||Array.isArray(u)||null===u||o===n||o instanceof Element||e(o,s)}))};return e(t)}function M(t,e=(()=>{})){let n={initialValue:void 0,_x_interceptor:!0,initialize(e,n,r){return t(this.initialValue,(()=>function(t,e){return e.split(".").reduce(((t,e)=>t[e]),t)}(e,n)),(t=>R(e,n,t)),n,r)}};return e(n),t=>{if("object"==typeof t&&null!==t&&t._x_interceptor){let e=n.initialize.bind(n);n.initialize=(r,i,o)=>{let a=t.initialize(r,i,o);return n.initialValue=a,e(r,i,o)}}else n.initialValue=t;return n}}function R(t,e,n){if("string"==typeof e&&(e=e.split(".")),1!==e.length){if(0===e.length)throw error;return t[e[0]]||(t[e[0]]={}),R(t[e[0]],e.slice(1),n)}t[e[0]]=n}var D={};function L(t,e){D[t]=e}function I(t,e){return Object.entries(D).forEach((([n,r])=>{let i=null;Object.defineProperty(t,`$${n}`,{get:()=>r(e,function(){if(i)return i;{let[t,n]=nt(e);return i={interceptor:M,...t},g(e,n),i}}()),enumerable:!1})})),t}function U(t,e,n,...r){try{return n(...r)}catch(n){F(n,t,e)}}function F(t,e,n=void 0){Object.assign(t,{el:e,expression:n}),console.warn(`Alpine Expression Error: ${t.message}\n\n${n?'Expression: "'+n+'"\n\n':""}`,e),setTimeout((()=>{throw t}),0)}var B=!0;function z(t,e,n={}){let r;return q(t,e)((t=>r=t),n),r}function q(...t){return H(...t)}var H=W;function W(t,e){let n={};I(n,t);let r=[n,...A(t)],i="function"==typeof e?function(t,e){return(n=(()=>{}),{scope:r={},params:i=[]}={})=>{$(n,e.apply(j([r,...t]),i))}}(r,e):function(t,e,n){let r=function(t,e){if(Y[t])return Y[t];let n=Object.getPrototypeOf((async function(){})).constructor,r=/^[\n\s]*if.*\(.*\)/.test(t)||/^(let|const)\s/.test(t)?`(async()=>{ ${t} })()`:t;const i=()=>{try{return new n(["__self","scope"],`with (scope) { __self.result = ${r} }; __self
Line truncated
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
*
|
|
||||||
* Push v1.0.9
|
|
||||||
* =========
|
|
||||||
* A compact, cross-browser solution for the JavaScript Notifications API
|
|
||||||
*
|
|
||||||
* Credits
|
|
||||||
* -------
|
|
||||||
* Tsvetan Tsvetkov (ttsvetko)
|
|
||||||
* Alex Gibson (alexgibson)
|
|
||||||
*
|
|
||||||
* License
|
|
||||||
* -------
|
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015-2017 Tyler Nickerson
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
!function(t,e){t.exports=function(){var t={errors:{incompatible:"".concat("PushError:"," Push.js is incompatible with browser."),invalid_plugin:"".concat("PushError:"," plugin class missing from plugin manifest (invalid plugin). Please check the documentation."),invalid_title:"".concat("PushError:"," title of notification must be a string"),permission_denied:"".concat("PushError:"," permission request declined"),sw_notification_error:"".concat("PushError:"," could not show a ServiceWorker notification due to the following reason: "),sw_registration_error:"".concat("PushError:"," could not register the ServiceWorker due to the following reason: "),unknown_interface:"".concat("PushError:"," unable to create notification: unknown interface")}};function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c=function(){function t(e){n(this,t),this._win=e,this.GRANTED="granted",this.DEFAULT="default",this.DENIED="denied",this._permissions=[this.GRANTED,this.DEFAULT,this.DENIED]}return i(t,[{key:"request",value:function(t,e){return arguments.length>0?this._requestWithCallback.apply(this,arguments):this._requestAsPromise()}},{key:"_requestWithCallback",value:function(t,e){var n,r=this,i=this.get(),o=!1,a=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r._win.Notification.permission;o||(o=!0,void 0===n&&r._win.webkitNotifications&&(n=r._win.webkitNotifications.checkPermission()),n===r.GRANTED||0===n?t&&t():e&&e())};i!==this.DEFAULT?a(i):this._win.webkitNotifications&&this._win.webkitNotifications.checkPermission?this._win.webkitNotifications.requestPermission(a):this._win.Notification&&this._win.Notification.requestPermission?(n=this._win.Notification.requestPermission(a))&&n.then&&n.then(a).catch((function(){e&&e()})):t&&t()}},{key:"_requestAsPromise",value:function(){var t=this,e=this.get(),n=e!==this.DEFAULT,r=this._win.Notification&&this._win.Notification.requestPermission,i=this._win.webkitNotifications&&this._win.webkitNotifications.checkPermission;return new Promise((function(o,a){var s,u=!1,c=function(e){u||(u=!0,function(e){return e===t.GRANTED||0===e}(e)?o():a())};n?c(e):i?t._win.webkitNotifications.requestPermission((function(t){c(t)})):r?(s=t._win.Notification.requestPermission(c))&&s.then&&s.then(c).catch(a):o()}))}},{key:"has",value:function(){return this.get()===this.GRANTED}},{key:"get",value:function(){return this._win.Notification&&this._win.Notification.permission?this._win.Notification.permission:this._win.webkitNotifications&&this._win.webkitNotifications.checkPermission?this._permissions[this._win.webkitNotifications.checkPermission()]:navigator.mozNotification?this.GRANTED:this._win.external&&this._win.external.msIsSiteMode?this._win.external.msIsSiteMode()?this.GRANTED:this.DEFAULT:this.GRANTED}}]),t}(),l=function(){function t(){n(this,t)}return i(t,null,[{key:"isUndefined",value:function(t){return void 0===t}},{key:"isNull",value:function(t){return null===obj}},{key:"isString",value:function(t){return"string"==typeof t}},{key:"isFunction",value:function(t){return t&&"[object Function]"==={}.toString.call(t)}},{key:"isObject",value:function(t){return"object"===e(t)}},{key:"objectMerge",value:function(t,e){for(var n in e)t.hasOwnProperty(n)&&this.isObject(t[n])&&this.isObject(e[n])?this.objectMerge(t[n],e[n]):t[n]=e[n]}}]),t}(),f=function t(e){n(this,t),this._win=e},h=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return o(e,f),i(e,[{key:"isSupported",value:function(){return void 0!==this._win.Notification}},{key:"create",value:function(t,e){return new this._win.Notification(t,{icon:l.isString(e.icon)||l.isUndefined(e.icon)||l.isNull(e.icon)?e.icon:e.icon.x32,body:e.body,tag:e.tag,requireInteraction:e.requireInteraction})}},{key:"close",value:function(t){t.close()}}]),e}(),d=function(e){function r(){return n(this,r),u(this,a(r).apLine truncated
|
|
||||||
/*!***************************************************
|
|
||||||
* mark.js v8.11.1
|
|
||||||
* https://markjs.io/
|
|
||||||
* Copyright (c) 2014–2018, Julian Kühnel
|
|
||||||
* Released under the MIT license https://git.io/vwTVl
|
|
||||||
*****************************************************/
|
|
||||||
!function(t,e){t.exports=function(){var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},n=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i=function(){function t(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;e(this,t),this.ctx=n,this.iframes=r,this.exclude=i,this.iframesTimeout=o}return n(t,[{key:"getContexts",value:function(){var t=[];return(void 0!==this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"==typeof this.ctx?Array.prototype.slice.call(document.querySelectorAll(this.ctx)):[this.ctx]:[]).forEach((function(e){var n=t.filter((function(t){return t.contains(e)})).length>0;-1!==t.indexOf(e)||n||t.push(e)})),t}},{key:"getIframeContents",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=void 0;try{var i=t.contentWindow;if(r=i.document,!i||!r)throw new Error("iframe inaccessible")}catch(t){n()}r&&e(r)}},{key:"isIframeBlank",value:function(t){var e="about:blank",n=t.getAttribute("src").trim();return t.contentWindow.location.href===e&&n!==e&&n}},{key:"observeIframeLoad",value:function(t,e,n){var r=this,i=!1,o=null,a=function a(){if(!i){i=!0,clearTimeout(o);try{r.isIframeBlank(t)||(t.removeEventListener("load",a),r.getIframeContents(t,e,n))}catch(t){n()}}};t.addEventListener("load",a),o=setTimeout(a,this.iframesTimeout)}},{key:"onIframeReady",value:function(t,e,n){try{"complete"===t.contentWindow.document.readyState?this.isIframeBlank(t)?this.observeIframeLoad(t,e,n):this.getIframeContents(t,e,n):this.observeIframeLoad(t,e,n)}catch(t){n()}}},{key:"waitForIframes",value:function(t,e){var n=this,r=0;this.forEachIframe(t,(function(){return!0}),(function(t){r++,n.waitForIframes(t.querySelector("html"),(function(){--r||e()}))}),(function(t){t||e()}))}},{key:"forEachIframe",value:function(e,n,r){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},a=e.querySelectorAll("iframe"),s=a.length,u=0;a=Array.prototype.slice.call(a);var c=function(){--s<=0&&o(u)};s||c(),a.forEach((function(e){t.matches(e,i.exclude)?c():i.onIframeReady(e,(function(t){n(e)&&(u++,r(t)),c()}),c)}))}},{key:"createIterator",value:function(t,e,n){return document.createNodeIterator(t,e,n,!1)}},{key:"createInstanceOnIframe",value:function(e){return new t(e.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(t,e,n){if(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING){if(null===e)return!0;if(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)return!0}return!1}},{key:"getIteratorNode",value:function(t){var e=t.previousNode();return{prevNode:e,node:(null===e||t.nextNode())&&t.nextNode()}}},{key:"checkIframeFilter",value:function(t,e,n,r){var i=!1,o=!1;return r.forEach((function(t,e){t.val===n&&(i=e,o=t.handled)})),this.compareNodeIframe(t,e,n)?(!1!==i||o?!1===i||o||(r[i].handled=!0):r.push({val:n,handled:!0}),!0):(!1===i&&r.push({val:n,handled:!1}),!1)}},{key:"handleOpenIframes",value:function(t,e,n,r){var i=this;t.forEach((function(t){t.handled||i.getIframeContents(t.val,(function(t){i.createInstanceOnIframe(t).forEachNode(e,n,r)}))}))}},{key:"iterateThroughNodes",value:function(t,e,n,r,i){for(var o=this,a=this.createIterator(e,t,r),s=[],u=[],c=void 0,l=void 0,f=function(){var t=o.getIteratorNode(a);return l=t.prevNode,c=t.node};f();)this.iframes&&this.forEachIframe(e,(function(t){return o.checkIframeFilter(c,l,t,s)}),(function(e){o.createInstanceOnIframe(e).forEachNode(t,(function(t){return u.push(t)}),r)})),u.push(c);u.forEach((function(t){n(t)})),this.iframes&&this.handleOpenIframes(s,t,n,r),i()}},{key:"forEachNode",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=this.getContexts(),a=o.length;a||i(),o.forEach((function(o){var s=function(){r.iterateThroughNodes(t,o,e,n,(function(){--a<=0&&i()}))};r.iframes?r.waitForIframes(o,s):s()}))}}],[{key:"matches",value:function(t,e){var n="string"==typeof e?[e]:e,r=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector;if(r){var i=!1;return n.every((function(e){return!r.call(t,e)||(i=!0,!1)})),i}return!1}}]),t}(),o=function(){function o(t){e(thiLine truncated
|
|
||||||
//# sourceMappingURL=basement.bundle.min.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"basement.bundle.min.js","sources":["../node_modules/alpinejs/dist/module.esm.js","../node_modules/axios/lib/helpers/bind.js","../node_modules/axios/lib/utils.js","../node_modules/axios/lib/core/AxiosError.js","../node_modules/axios/lib/helpers/toFormData.js","../node_modules/axios/lib/helpers/AxiosURLSearchParams.js","../node_modules/axios/lib/helpers/buildURL.js","../node_modules/axios/lib/core/InterceptorManager.js","../node_modules/axios/lib/defaults/transitional.js","../node_modules/axios/lib/platform/browser/index.js","../node_modules/axios/lib/platform/browser/classes/URLSearchParams.js","../node_modules/axios/lib/platform/browser/classes/FormData.js","../node_modules/axios/lib/platform/browser/classes/Blob.js","../node_modules/axios/lib/helpers/formDataToJSON.js","../node_modules/axios/lib/defaults/index.js","../node_modules/axios/lib/helpers/toURLEncodedForm.js","../node_modules/axios/lib/helpers/parseHeaders.js","../node_modules/axios/lib/core/AxiosHeaders.js","../node_modules/axios/lib/core/transformData.js","../node_modules/axios/lib/cancel/isCancel.js","../node_modules/axios/lib/cancel/CanceledError.js","../node_modules/axios/lib/helpers/cookies.js","../node_modules/axios/lib/core/buildFullPath.js","../node_modules/axios/lib/helpers/isAbsoluteURL.js","../node_modules/axios/lib/helpers/combineURLs.js","../node_modules/axios/lib/helpers/isURLSameOrigin.js","../node_modules/axios/lib/adapters/xhr.js","../node_modules/axios/lib/helpers/speedometer.js","../node_modules/axios/lib/core/settle.js","../node_modules/axios/lib/helpers/parseProtocol.js","../node_modules/axios/lib/adapters/adapters.js","../node_modules/axios/lib/helpers/null.js","../node_modules/axios/lib/core/dispatchRequest.js","../node_modules/axios/lib/core/mergeConfig.js","../node_modules/axios/lib/env/data.js","../node_modules/axios/lib/helpers/validator.js","../node_modules/axios/lib/core/Axios.js","../node_modules/axios/lib/cancel/CancelToken.js","../node_modules/axios/lib/helpers/HttpStatusCode.js","../node_modules/axios/lib/axios.js","../node_modules/axios/lib/helpers/spread.js","../node_modules/axios/lib/helpers/isAxiosError.js","../node_modules/laravel-echo/dist/echo.js","../node_modules/pusher-js/dist/web/pusher.js","../node_modules/core-js/internals/global.js","../node_modules/core-js/internals/fails.js","../node_modules/core-js/internals/descriptors.js","../node_modules/core-js/internals/function-bind-native.js","../node_modules/core-js/internals/function-call.js","../node_modules/core-js/internals/object-property-is-enumerable.js","../node_modules/core-js/internals/create-property-descriptor.js","../node_modules/core-js/internals/engine-v8-version.js","../node_modules/core-js/internals/function-uncurry-this.js","../node_modules/core-js/internals/classof-raw.js","../node_modules/core-js/internals/indexed-object.js","../node_modules/core-js/internals/is-null-or-undefined.js","../node_modules/core-js/internals/require-object-coercible.js","../node_modules/core-js/internals/to-indexed-object.js","../node_modules/core-js/internals/document-all.js","../node_modules/core-js/internals/is-callable.js","../node_modules/core-js/internals/is-object.js","../node_modules/core-js/internals/get-built-in.js","../node_modules/core-js/internals/object-is-prototype-of.js","../node_modules/core-js/internals/engine-user-agent.js","../node_modules/core-js/internals/symbol-constructor-detection.js","../node_modules/core-js/internals/use-symbol-as-uid.js","../node_modules/core-js/internals/is-symbol.js","../node_modules/core-js/internals/try-to-string.js","../node_modules/core-js/internals/a-callable.js","../node_modules/core-js/internals/get-method.js","../node_modules/core-js/internals/ordinary-to-primitive.js","../node_modules/core-js/internals/define-global-property.js","../node_modules/core-js/internals/shared-store.js","../node_modules/core-js/internals/shared.js","../node_modules/core-js/internals/to-object.js","../node_modules/core-js/internals/has-own-property.js","../node_modules/core-js/internals/uid.js","../node_modules/core-js/internals/well-known-symbol.js","../node_modules/core-js/internals/to-primitive.js","../node_modules/core-js/internals/to-property-key.js","../node_modules/core-js/internals/document-create-element.js","../node_modules/core-js/internals/ie8-dom-define.js","../node_modules/core-js/internals/object-get-own-property-descriptor.js","../node_modules/core-js/internals/v8-prototype-define-bug.js","../node_modules/core-js/internals/an-object.js","../node_modules/core-js/internals/object-define-property.js","../node_modules/core-js/internals/create-non-enumerable-property.js","../node_modules/core-js/internals/function-name.js","../node_modules/core-js/internals/inspect-source.js","../node_modules/core-js/internals/internal-state.js","../node_modules/core-js/internals/weak-map-basic-detection.js","../node_modules/core-js/internals/shared-key.js","../node_modules/core-js/internals/hidden-keys.js","../noLine truncated
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Test</title>
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ asset('vendor/basement/basement.bundle.min.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Test</h1>
|
|
||||||
|
|
||||||
@auth
|
|
||||||
<x-basement::chat-box />
|
|
||||||
@endauth
|
|
||||||
|
|
||||||
<script src="{{ asset('vendor/basement/basement.bundle.min.js') }}"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Http\Controllers\Api\V1\CartController;
|
use App\Http\Controllers\Api\V1\CartController;
|
||||||
use App\Http\Controllers\Api\V1\Category\CategoryController;
|
use App\Http\Controllers\Api\V1\Category\CategoryController;
|
||||||
use App\Http\Controllers\Api\V1\Channel\ChannelController;
|
use App\Http\Controllers\Api\V1\Channel\ChannelController;
|
||||||
|
use App\Http\Controllers\Api\V1\Chat\ChatController;
|
||||||
use App\Http\Controllers\Api\V1\Collection\CollectionController;
|
use App\Http\Controllers\Api\V1\Collection\CollectionController;
|
||||||
use App\Http\Controllers\Api\V1\ContactMessageController;
|
use App\Http\Controllers\Api\V1\ContactMessageController;
|
||||||
use App\Http\Controllers\Api\V1\Favorite\FavoriteController;
|
use App\Http\Controllers\Api\V1\Favorite\FavoriteController;
|
||||||
@@ -107,18 +108,19 @@
|
|||||||
// Global orders...
|
// Global orders...
|
||||||
Route::post('global-order', [GlobalOrderController::class, 'store']);
|
Route::post('global-order', [GlobalOrderController::class, 'store']);
|
||||||
|
|
||||||
// Route::middleware('auth:sanctum')->group(function () {
|
|
||||||
// Route::get('/chat/contacts', [ChatController::class, 'contacts']);
|
|
||||||
// Route::get('/chat/messages/{conversation}', [ChatController::class, 'messages']);
|
|
||||||
// Route::post('/chat/start', [ChatController::class, 'start']);
|
|
||||||
// Route::post('/chat/send', [ChatController::class, 'send']);
|
|
||||||
// });
|
|
||||||
|
|
||||||
Route::middleware(['auth:sanctum', 'banned'])->group(function () {
|
Route::middleware(['auth:sanctum', 'banned'])->group(function () {
|
||||||
// Profile...
|
// Profile...
|
||||||
Route::get('profile', [ProfileController::class, 'index']);
|
Route::get('profile', [ProfileController::class, 'index']);
|
||||||
Route::post('profile', [ProfileController::class, 'store']);
|
Route::post('profile', [ProfileController::class, 'store']);
|
||||||
|
|
||||||
|
// Chat...
|
||||||
|
Route::get('chat/conversations', [ChatController::class, 'conversations']);
|
||||||
|
Route::get('chat/contacts', [ChatController::class, 'contacts']);
|
||||||
|
Route::post('chat/start', [ChatController::class, 'start']);
|
||||||
|
Route::get('chat/conversations/{conversation}/messages', [ChatController::class, 'messages'])->where(['conversation' => '[0-9]+']);
|
||||||
|
Route::post('chat/conversations/{conversation}/messages', [ChatController::class, 'send'])->where(['conversation' => '[0-9]+']);
|
||||||
|
Route::post('chat/conversations/{conversation}/read', [ChatController::class, 'read'])->where(['conversation' => '[0-9]+']);
|
||||||
|
|
||||||
// Cart items...
|
// Cart items...
|
||||||
Route::get('carts', [CartController::class, 'index']);
|
Route::get('carts', [CartController::class, 'index']);
|
||||||
Route::post('carts', [CartController::class, 'store']);
|
Route::post('carts', [CartController::class, 'store']);
|
||||||
|
|||||||
Reference in new issue
Block a user