Răsfoiți Sursa

fix: :bug: fix (foto e reviews) corrigido fotos e reviews

corrigido alguns lugares que a foto nao carregava corretamente + reviews

fase:dev | origin:melhoria-interna
Gustavo Zanatta 4 zile în urmă
părinte
comite
d6e0470b8f

+ 1 - 0
app/Http/Resources/CardsListResource.php

@@ -14,6 +14,7 @@ class CardsListResource extends JsonResource
             'brand'            => $this->brand,
             'last_four_digits' => $this->last_four_digits,
             'card_name'        => $this->card_name,
+            'holder_name'      => $this->holder_name
 
         ];
     }

+ 1 - 0
app/Http/Resources/ReviewDetailResource.php

@@ -46,6 +46,7 @@ class ReviewDetailResource extends JsonResource
                     'name'  => $schedule->client->user?->name,
                     'email' => $schedule->client->user?->email,
                     'phone' => $schedule->client->user?->phone,
+                    'profile_photo' => $schedule->client->profile_photo
                 ] : null,
 
                 'provider' => $schedule->provider ? [

+ 1 - 0
app/Models/Schedule.php

@@ -101,6 +101,7 @@ class Schedule extends Model
             'average_rating',
             'gateway_customer_id',
             'gateway_customer_code',
+            'profile_media_id',
         );
     }
 

+ 2 - 1
app/Services/ClientPaymentMethodService.php

@@ -20,7 +20,8 @@ class ClientPaymentMethodService
                 'id',
                 'brand',
                 'last_four_digits',
-                'card_name'
+                'card_name',
+                'holder_name'
             )
             ->orderBy('is_active', 'desc')
             ->orderBy('created_at', 'desc')

+ 2 - 1
app/Services/DashboardService.php

@@ -58,7 +58,8 @@ class DashboardService
                 : null,
             'address'          => $address,
             'pending_services' => Schedule::where('client_id', $cliente->id)
-                ->where('status', 'pending')
+                ->whereIn('status', ['pending', 'paid', 'accepted'])
+                ->whereDate('date', '>=', now()->toDateString())
                 ->count(),
         ];
 

+ 13 - 1
app/Services/ReviewService.php

@@ -13,6 +13,7 @@ use App\Models\Schedule;
 use Exception;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Storage;
 
 class ReviewService
 {
@@ -156,6 +157,7 @@ class ReviewService
     {
         return [
             'schedule.client.user',
+            'schedule.client.profileMedia',
             'schedule.provider.user',
             'schedule.address.city',
             'schedule.address.state',
@@ -194,11 +196,21 @@ class ReviewService
 
     public function getByProviderReceived(int $providerId)
     {
-        return Review::with($this->detailEagerLoads())
+        $reviews = Review::with($this->detailEagerLoads())
             ->whereIn('origin', ['client', 'clients'])
             ->whereHas('schedule', fn ($q) => $q->where('provider_id', $providerId))
             ->orderBy('created_at', 'desc')
             ->get();
+
+        foreach ($reviews as $review) {
+            if ($review->schedule?->client?->profileMedia?->path) {
+                $review->schedule->client->profile_photo = Storage::temporaryUrl($review->schedule->client->profileMedia->path, now()->addMinutes(60));
+            } else {
+                $review->schedule->client->profile_photo = null;
+            }
+        }
+
+        return $reviews;
     }
 
     public function update(int $id, array $data): Review