Преглед на файлове

Fix type hinting for TwoFAccount resources

Bubka преди 3 години
родител
ревизия
77234ddc66
променени са 2 файла, в които са добавени 5 реда и са изтрити 5 реда
  1. 2 2
      app/Api/v1/Resources/TwoFAccountReadResource.php
  2. 3 3
      app/Api/v1/Resources/TwoFAccountStoreResource.php

+ 2 - 2
app/Api/v1/Resources/TwoFAccountReadResource.php

@@ -14,8 +14,8 @@ class TwoFAccountReadResource extends TwoFAccountStoreResource
     {
         return array_merge(
             [
-                'id'            => $this->id,
-                'group_id'      => intval($this->group_id),
+                'id'            => (int) $this->id,
+                'group_id'      => is_null($this->group_id) ? null : (int) $this->group_id,
             ],
             parent::toArray($request)
         );

+ 3 - 3
app/Api/v1/Resources/TwoFAccountStoreResource.php

@@ -23,10 +23,10 @@ class TwoFAccountStoreResource extends JsonResource
                                     !$request->has('withSecret') || (int) filter_var($request->input('withSecret'), FILTER_VALIDATE_BOOLEAN) == 1,
                                     $this->secret
                                 ),
-            'digits'        => $this->digits,
+            'digits'        => (int) $this->digits,
             'algorithm'     => $this->algorithm,
-            'period'        => $this->period,
-            'counter'       => $this->counter
+            'period'        => is_null($this->period) ? null : (int)$this->period,
+            'counter'       => is_null($this->counter) ? null : (int)$this->counter
         ];
     }
 }