diff --git a/Modules/Admin/Support/HomeSlideFormSchema.php b/Modules/Admin/Support/HomeSlideFormSchema.php index 49b354271..3ae1b5f42 100644 --- a/Modules/Admin/Support/HomeSlideFormSchema.php +++ b/Modules/Admin/Support/HomeSlideFormSchema.php @@ -57,7 +57,6 @@ final class HomeSlideFormSchema ->reorderableWithButtons() ->addActionLabel('Add Slide') ->itemLabel(fn (array $state): string => filled($state['title'] ?? null) ? (string) $state['title'] : 'New Slide') - ->afterStateHydrated(fn (Repeater $component, $state) => $component->state($normalizeSlides($state))) ->dehydrateStateUsing(fn ($state) => $normalizeSlides($state)); } } diff --git a/Modules/Category/Models/Category.php b/Modules/Category/Models/Category.php index 55c092c0b..24d3e9337 100644 --- a/Modules/Category/Models/Category.php +++ b/Modules/Category/Models/Category.php @@ -95,6 +95,16 @@ class Category extends Model ->get(['id', 'name', 'slug']); } + public static function seedableListingFieldCategories(): Collection + { + return static::query() + ->active() + ->with('parent:id,name,slug,parent_id') + ->ordered() + ->get() + ->values(); + } + public static function rootTreeWithActiveChildren(): Collection { return static::query() diff --git a/Modules/Favorite/App/Http/Controllers/FavoriteController.php b/Modules/Favorite/App/Http/Controllers/FavoriteController.php index 74d0fcd5b..e140cc3e2 100644 --- a/Modules/Favorite/App/Http/Controllers/FavoriteController.php +++ b/Modules/Favorite/App/Http/Controllers/FavoriteController.php @@ -8,7 +8,6 @@ use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Facades\Schema; use Modules\Category\Models\Category; use Modules\Conversation\App\Models\Conversation; -use Modules\Conversation\App\Support\QuickMessageCatalog; use Modules\Favorite\App\Models\FavoriteSearch; use Modules\Listing\Models\Listing; use Modules\User\App\Models\User; @@ -28,11 +27,6 @@ class FavoriteController extends Controller $statusFilter = 'all'; } - $messageFilter = (string) $request->string('message_filter', 'all'); - if (! in_array($messageFilter, ['all', 'unread', 'important'], true)) { - $messageFilter = 'all'; - } - $selectedCategoryId = $request->integer('category'); if ($selectedCategoryId <= 0) { $selectedCategoryId = null; @@ -52,8 +46,6 @@ class FavoriteController extends Controller $favoriteListings = $this->emptyPaginator(); $favoriteSearches = $this->emptyPaginator(); $favoriteSellers = $this->emptyPaginator(); - $conversations = collect(); - $selectedConversation = null; $buyerConversationListingMap = []; if ($user && $activeTab === 'listings') { @@ -69,34 +61,20 @@ class FavoriteController extends Controller ->withQueryString(); } - if ($this->tableExists('conversations') && $this->tableExists('conversation_messages')) { + if ( + $favoriteListings->isNotEmpty() + && $this->tableExists('conversations') + ) { $userId = (int) $user->getKey(); - $conversations = Conversation::inboxForUser($userId, $messageFilter); - $buyerConversationListingMap = $conversations + $buyerConversationListingMap = Conversation::query() ->where('buyer_id', $userId) + ->whereIn('listing_id', $favoriteListings->pluck('id')->all()) ->pluck('id', 'listing_id') ->map(fn ($conversationId) => (int) $conversationId) ->all(); - - $selectedConversation = Conversation::resolveSelected($conversations, $request->integer('conversation')); - - if ($selectedConversation) { - $selectedConversation->loadThread(); - $selectedConversation->markAsReadFor($userId); - - $conversations = $conversations->map(function (Conversation $conversation) use ($selectedConversation): Conversation { - if ((int) $conversation->getKey() === (int) $selectedConversation->getKey()) { - $conversation->unread_count = 0; - } - - return $conversation; - }); - } } } catch (Throwable) { $favoriteListings = $this->emptyPaginator(); - $conversations = collect(); - $selectedConversation = null; $buyerConversationListingMap = []; } } @@ -135,15 +113,11 @@ class FavoriteController extends Controller 'activeTab' => $activeTab, 'statusFilter' => $statusFilter, 'selectedCategoryId' => $selectedCategoryId, - 'messageFilter' => $messageFilter, 'categories' => $categories, 'favoriteListings' => $favoriteListings, 'favoriteSearches' => $favoriteSearches, 'favoriteSellers' => $favoriteSellers, - 'conversations' => $conversations, - 'selectedConversation' => $selectedConversation, 'buyerConversationListingMap' => $buyerConversationListingMap, - 'quickMessages' => QuickMessageCatalog::all(), 'requiresLogin' => $requiresLogin, ]); } diff --git a/Modules/Favorite/resources/views/index.blade.php b/Modules/Favorite/resources/views/index.blade.php index c96e41efa..63b3a2ce6 100644 --- a/Modules/Favorite/resources/views/index.blade.php +++ b/Modules/Favorite/resources/views/index.blade.php @@ -26,7 +26,6 @@ 'tab' => 'listings', 'status' => $statusFilter, 'category' => $selectedCategoryId, - 'message_filter' => $messageFilter, ], fn ($value) => !is_null($value) && $value !== ''); @endphp