]> _ Git - psq.git/commitdiff
add fin essai
authorLouis Jeckel <louis.jeckel@outlook.cm>
Fri, 11 Sep 2020 14:16:53 +0000 (16:16 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Fri, 11 Sep 2020 14:16:53 +0000 (16:16 +0200)
app/Nova/DiscoverUsers.php
app/Nova/User.php

index f5350a1410d4b23125e6c757503271c49ad3dc64..963a12d3c15401e0cfd85b38b893a04508d34c2d 100644 (file)
@@ -4,6 +4,9 @@
 namespace App\Nova;
 
 
+use Carbon\Carbon;
+use Laravel\Nova\Fields\DateTime;
+use Laravel\Nova\Fields\Text;
 use Laravel\Nova\Http\Requests\NovaRequest;
 
 class DiscoverUsers extends User
@@ -24,5 +27,18 @@ class DiscoverUsers extends User
     }
 
 
+    protected function extraFields()
+    {
+        return [
+            Text::make('Fin essai', function() {
+                /** @var Carbon $date */
+               $date = $this->trial_ends_at ?? $this->discover_ends_at;
+               return $date === null ?
+                   null :
+                   $date->format('d/m/Y');
+            })
+        ];
+    }
+
 
 }
index 4e88bd4f3745512ffc0f03a8dc954c5832b0aff6..b096d46afc729fa88cbe9ff76873af865ab9e06f 100644 (file)
@@ -59,7 +59,7 @@ class User extends Resource
      */
     public function fields(Request $request)
     {
-        return [
+        return array_merge([
 //            ID::make()->sortable(),
             Text::make('Prénom', 'first_name'),
             Text::make('Nom', 'last_name'),
@@ -70,6 +70,7 @@ class User extends Resource
             new Panel('Affiliation', [
                 BelongsTo::make('Organisation', 'organization', Organization::class)->searchable()->nullable(),
             ]),
+            ], $this->extraFields(), [
             Boolean::make('Compte activé', 'reg_complete')->hideWhenCreating(),
             Select::make('Type')->options([
                 AppUser::TYPE_SUBSCRIBER => 'Abonné',
@@ -79,9 +80,16 @@ class User extends Resource
             ])->hideFromIndex()->required()->withMeta(['value' => $this->type ?? static::$type ?? AppUser::TYPE_SUBSCRIBER]),
             Badge::make('Etat', fn() => AppUser::STATUSES[$this->status]['label'])
                 ->map(Arr::pluck(AppUser::STATUSES, 'badge', 'label')),
-        ];
+        ]);
     }
 
+    /**
+     * @return array
+     */
+    protected function extraFields()
+    {
+        return [];
+    }
 
     /**
      * Get the address fields for the resource.