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:
Mekan1206 committed 2026-08-15 21:17:31 +05:00
1 parent c55694ec8c
commit 5c17c35741
23 files changed
+729 -59

No files matched your search

@@ -8,7 +8,9 @@
use App\Nova\Resources\Ecommerce\Channel\Fields\ChannelFieldsForIndex;
use App\Nova\Resources\Ecommerce\Product\Product\Product;
use App\Nova\Resources\User\UserSearchResource;
use App\Support\ChatSupport;
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
use Illuminate\Database\Eloquent\Builder;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\Hidden;
@@ -81,6 +83,49 @@ public function fieldsForIndex(): array
return ChannelFieldsForIndex::make();
}
/**
* Build an "index" query for the given resource.
*
* @param Builder $query
*/
public static function indexQuery(NovaRequest $request, $query): Builder
{
$user = $request->user();
if ($user && $user->isVendor() && ! ChatSupport::isOperator($user)) {
$query->where('channelables_type', User::class)
->where('channelables_id', $user->id);
}
return $query;
}
/**
* Build a "detail" query for the given resource.
*
* @param Builder $query
*/
public static function detailQuery(NovaRequest $request, $query): Builder
{
return static::indexQuery($request, parent::detailQuery($request, $query));
}
/**
* Fields vendors may change (chatting only).
*/
public function fieldsForUpdate(NovaRequest $request): array
{
$user = $request->user();
if ($user && $user->isVendor() && ! ChatSupport::isOperator($user)) {
return [
NovaSwitcher::make(__('Chatting'), 'chatting'),
];
}
return $this->fields($request);
}
/**
* Get the fields displayed by the resource.
*/
@@ -125,6 +170,9 @@ public function fields(NovaRequest $request): array
NovaSwitcher::make(__('Active'), 'is_visible')
->default(true),
NovaSwitcher::make(__('Chatting'), 'chatting')
->default(false),
MorphMany::make(__('Products'), 'products', Product::class),
];
}