Browse Source

fix: banner de dados de pagamento apenas no primeiro acesso do cliente

Gustavo Zanatta 5 days ago
parent
commit
5f757241ca

+ 1 - 0
app/Http/Requests/UpdateMeRequest.php

@@ -31,6 +31,7 @@ class UpdateMeRequest extends FormRequest
             'avatar'        => 'sometimes|file|image|mimes:jpg,jpeg,png,webp|max:5120',
             'avatar'        => 'sometimes|file|image|mimes:jpg,jpeg,png,webp|max:5120',
             'avatar_base64' => 'sometimes|string|nullable',
             'avatar_base64' => 'sometimes|string|nullable',
             'push_notifications_enabled' => 'sometimes|boolean',
             'push_notifications_enabled' => 'sometimes|boolean',
+            'first_access'  => 'sometimes|boolean',
         ];
         ];
     }
     }
 }
 }

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

@@ -19,6 +19,7 @@ class ClientResource extends JsonResource
             'document'         => $this->document,
             'document'         => $this->document,
             'user_id'          => $this->user_id,
             'user_id'          => $this->user_id,
             'selfie_verified'  => $this->selfie_verified,
             'selfie_verified'  => $this->selfie_verified,
+            'first_access'     => $this->first_access,
             'profile_media_id' => $this->profileMedia?->id,
             'profile_media_id' => $this->profileMedia?->id,
             'profile_media'    => $this->profileMedia ? new MediaResource($this->profileMedia) : null,
             'profile_media'    => $this->profileMedia ? new MediaResource($this->profileMedia) : null,
             'user'             => new UserResource($this->whenLoaded('user')),
             'user'             => new UserResource($this->whenLoaded('user')),

+ 3 - 0
app/Models/Client.php

@@ -23,6 +23,7 @@ use Illuminate\Support\Facades\Auth;
  * @property string|null $gateway_customer_code
  * @property string|null $gateway_customer_code
  * @property int|null $profile_media_id
  * @property int|null $profile_media_id
  * @property bool $selfie_verified
  * @property bool $selfie_verified
+ * @property bool $first_access
  * @property string|null $idempotency_key
  * @property string|null $idempotency_key
  * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProviderClientBlock> $blockedByProviders
  * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProviderClientBlock> $blockedByProviders
  * @property-read int|null $blocked_by_providers_count
  * @property-read int|null $blocked_by_providers_count
@@ -64,6 +65,7 @@ class Client extends Model
         'user_id',
         'user_id',
         'profile_media_id',
         'profile_media_id',
         'selfie_verified',
         'selfie_verified',
+        'first_access',
     ];
     ];
 
 
     protected $casts = [
     protected $casts = [
@@ -71,6 +73,7 @@ class Client extends Model
         'updated_at'      => 'datetime',
         'updated_at'      => 'datetime',
         'deleted_at'      => 'datetime',
         'deleted_at'      => 'datetime',
         'selfie_verified' => 'boolean',
         'selfie_verified' => 'boolean',
+        'first_access'    => 'boolean',
     ];
     ];
 
 
     public function user(): BelongsTo
     public function user(): BelongsTo

+ 8 - 0
app/Services/UserService.php

@@ -118,6 +118,14 @@ class UserService
                 $client->save();
                 $client->save();
             }
             }
 
 
+            if (array_key_exists('first_access', $data)) {
+                $client = $user->client ?? Client::create(['user_id' => $user->id]);
+
+                $client->first_access = data_get($data, 'first_access');
+
+                $client->save();
+            }
+
             if (data_get($data, 'avatar') !== null && data_get($data, 'avatar') instanceof UploadedFile) {
             if (data_get($data, 'avatar') !== null && data_get($data, 'avatar') instanceof UploadedFile) {
                 $client = $user->client ?? Client::create(['user_id' => $user->id]);
                 $client = $user->client ?? Client::create(['user_id' => $user->id]);
 
 

+ 28 - 0
database/migrations/2026_08_24_000000_add_first_access_to_clients_table.php

@@ -0,0 +1,28 @@
+<?php
+
+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::table('clients', function (Blueprint $table) {
+            $table->boolean('first_access')->default(true)->after('selfie_verified');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('clients', function (Blueprint $table) {
+            $table->dropColumn('first_access');
+        });
+    }
+};