mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
34 lines
874 B
PHP
34 lines
874 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class UserRewardResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$emailReminder = null;
|
|
if ($request->has('isAdmin')) {
|
|
$keyValuePairs = $this->user->attributesKVP()->get();
|
|
$emailReminder = KeyValueBasicResource::collection($keyValuePairs);
|
|
$this->voucher->email = $emailReminder;
|
|
}
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
'user_id' => $this->user_id,
|
|
'reward' => new RewardResource($this->reward),
|
|
'voucher' => new VoucherResource($this->voucher),
|
|
'created_at' => $this->created_at
|
|
];
|
|
}
|
|
}
|