]> _ Git - psq.git/commitdiff
stats compte
authorLouis Jeckel <louis.jeckel@outlook.cm>
Tue, 1 Sep 2020 08:41:04 +0000 (10:41 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Tue, 1 Sep 2020 08:41:04 +0000 (10:41 +0200)
app/Imports/UsersImport.php
app/Nova/Metrics/RegistrationCompletePartition.php [new file with mode: 0644]
app/Nova/Metrics/UsersPartition.php
app/Nova/User.php
app/User.php

index 524ed0f280f0da2afd62864d70439b2beaf90eee..d4fdad784be18af10fc265bfcd95185a0a4284d3 100644 (file)
@@ -48,9 +48,9 @@ class UsersImport implements ToModel, WithValidation, WithHeadingRow
         $phone = implode('', $digits[0]);
 
         return new User([
-            'first_name' => Str::title($row['first_name']),
-            'last_name' => Str::title($row['last_name']),
-            'email' => Str::lower($row['email']),
+            'first_name' => trim(Str::title($row['first_name'])),
+            'last_name' => trim(Str::title($row['last_name'])),
+            'email' => trim(Str::lower($row['email'])),
             'position' => Str::title($row['position']),
             'organization_id' => $org ? $org->id : null,
             'address_line_1' => $row['address_line_1'],
diff --git a/app/Nova/Metrics/RegistrationCompletePartition.php b/app/Nova/Metrics/RegistrationCompletePartition.php
new file mode 100644 (file)
index 0000000..ca0499a
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace App\Nova\Metrics;
+
+use App\User;
+use Laravel\Nova\Http\Requests\NovaRequest;
+use Laravel\Nova\Metrics\Partition;
+
+class RegistrationCompletePartition extends Partition
+{
+
+    public $name = "Comptes activés";
+
+    /**
+     * Calculate the value of the metric.
+     *
+     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
+     * @return mixed
+     */
+    public function calculate(NovaRequest $request)
+    {
+        return $this->result([
+            'Compte activé' => User::registrationComplete()->count(),
+            'Compte non activé' => User::registrationIncomplete()->count(),
+        ]);
+    }
+
+    /**
+     * Determine for how many minutes the metric should be cached.
+     *
+     * @return  \DateTimeInterface|\DateInterval|float|int
+     */
+    public function cacheFor()
+    {
+//         return now()->addMinutes(5);
+    }
+
+    /**
+     * Get the URI key for the metric.
+     *
+     * @return string
+     */
+    public function uriKey()
+    {
+        return 'registration-complete';
+    }
+    
+}
index 52c446731f27c75f822bec1d2d055b372180e99f..ee9bd9c17fab0597b9fdc3d216fefd37c8971442 100644 (file)
@@ -20,10 +20,10 @@ class UsersPartition extends Partition
     public function calculate(NovaRequest $request)
     {
         return $this->result([
-            'Abonnés (groupe)' => $s = User::hasOrgSubscription()->count(),
-            'Abonnés (indiv)' => $s = User::hasIndSubscription()->count(),
+            'Abonnés (groupe)' => $g = User::hasOrgSubscription()->count(),
+            'Abonnés (indiv)' => $i = User::hasIndSubscription()->count(),
             "Période d'essai" => $t = User::isOnTrial()->count(),
-            "Reste" => User::count() - $s - $t
+            "Reste" => User::count() - $i - $g - $t
         ]);
     }
 
index 991ab99cbbc9cda0432b8e9d0b91c5a7e83fe6a0..1b2537d30859f94d8ae4ab76a5d5048d01f96aa2 100644 (file)
@@ -6,6 +6,7 @@ use App\Nova\Actions\ImportUsers;
 use App\Nova\Actions\SendNotification;
 use App\Nova\Actions\StartTrial;
 use App\Nova\Actions\VerifyEmail;
+use App\Nova\Metrics\RegistrationCompletePartition;
 use App\Nova\Metrics\SubscribedUsers;
 use App\Nova\Metrics\TotalUsers;
 use App\Nova\Metrics\TrialUsers;
@@ -107,6 +108,7 @@ class User extends Resource
         return [
             new TotalUsers,
             new UsersPartition,
+            new RegistrationCompletePartition
         ];
     }
 
index 4836338fe5ce064dc105e76f0452dd87e7604e87..cceda4c4160cfc391d2f75fd51c58ba85eba52b6 100644 (file)
@@ -297,6 +297,24 @@ class User extends Authenticatable implements MustVerifyEmail
         $builder->where('type', self::TYPE_SUBSCRIBER);
     }
 
+    /**
+     * @param Builder $builder
+     */
+    public function scopeRegistrationComplete(Builder $builder): void
+    {
+        $builder->where('reg_complete', 1);
+    }
+
+
+    /**
+     * @param Builder $builder
+     */
+    public function scopeRegistrationIncomplete(Builder $builder): void
+    {
+        $builder->where('reg_complete', 0);
+    }
+
+