mkA~(@^_^@)~PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT p0 multiple_attachment = true; $this->multiple_attachment_usage = ['default', 'bdf-file']; } public function getImageAttribute() { return $this->attachmentRelation()->first(); } public function mainCategory(): BelongsTo { return $this->belongsTo(Category::class, 'main_category_id'); } public function subCategory(): BelongsTo { return $this->belongsTo(Category::class, 'sub_category_id'); } public function favoritedByUsers() { return $this->belongsToMany(User::class, 'favourites')->withTimestamps(); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function rfqs() { return $this->hasMany(RFQ::class); } public function specs(): HasMany { return $this->hasMany(Spec::class); } public function getIsFavAttribute() { return $this->favoritedByUsers()->where('user_id', auth()->id())->exists(); } public function getIsInCartAttribute() { $userId = auth()->id(); if (!$userId) { return false; // No authenticated user } // Check if the product exists in the user's cart return \App\Models\CartItem::whereHas('cart', function ($query) use ($userId) { $query->where('user_id', $userId); })->where('product_id', $this->id)->exists(); } }