2022-09-21 12:59:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
class UserResource extends JsonResource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
|
|
|
$personalData = \Auth::id() === $this->id ? [
|
|
|
|
'is_subscribed' => $this->is_subscribed,
|
|
|
|
'has_enterprise_subscription' => $this->has_enterprise_subscription,
|
|
|
|
'admin' => $this->admin,
|
2024-01-19 13:27:04 +00:00
|
|
|
'moderator' => $this->moderator,
|
2022-11-16 12:12:48 +00:00
|
|
|
'template_editor' => $this->template_editor,
|
2022-09-21 12:59:32 +00:00
|
|
|
'has_customer_id' => $this->has_customer_id,
|
|
|
|
'has_forms' => $this->has_forms,
|
2023-11-01 15:58:10 +00:00
|
|
|
'active_license' => $this->licenses()->active()->first(),
|
2022-09-21 12:59:32 +00:00
|
|
|
] : [];
|
|
|
|
|
|
|
|
return array_merge(parent::toArray($request), $personalData);
|
|
|
|
}
|
|
|
|
}
|