2021-09-18 00:00:39 +02:00
|
|
|
<?php
|
|
|
|
|
2021-11-07 21:57:22 +01:00
|
|
|
namespace App\Api\v1\Resources;
|
2021-09-18 00:00:39 +02:00
|
|
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
2022-09-07 17:54:27 +02:00
|
|
|
/**
|
|
|
|
* @property mixed $otp_type
|
|
|
|
* @property string $account
|
|
|
|
* @property string $service
|
|
|
|
* @property string $icon
|
|
|
|
* @property string $secret
|
|
|
|
* @property int $digits
|
|
|
|
* @property string $algorithm
|
|
|
|
* @property int|null $period
|
|
|
|
* @property int|null $counter
|
|
|
|
*/
|
2021-09-18 00:00:39 +02:00
|
|
|
class TwoFAccountStoreResource extends JsonResource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
|
|
|
return [
|
2022-11-22 15:15:52 +01:00
|
|
|
'otp_type' => $this->otp_type,
|
|
|
|
'account' => $this->account,
|
|
|
|
'service' => $this->service,
|
|
|
|
'icon' => $this->icon,
|
|
|
|
'secret' => $this->when(
|
|
|
|
! $request->has('withSecret') || (int) filter_var($request->input('withSecret'), FILTER_VALIDATE_BOOLEAN) == 1,
|
|
|
|
$this->secret
|
|
|
|
),
|
|
|
|
'digits' => (int) $this->digits,
|
|
|
|
'algorithm' => $this->algorithm,
|
|
|
|
'period' => is_null($this->period) ? null : (int) $this->period,
|
|
|
|
'counter' => is_null($this->counter) ? null : (int) $this->counter,
|
2021-09-18 00:00:39 +02:00
|
|
|
];
|
|
|
|
}
|
2022-11-22 15:15:52 +01:00
|
|
|
}
|