Improved DB performance & loading times (#1)
This commit is contained in:
27
app/Http/Resources/UserResource.php
Normal file
27
app/Http/Resources/UserResource.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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,
|
||||
'has_customer_id' => $this->has_customer_id,
|
||||
'has_forms' => $this->has_forms,
|
||||
] : [];
|
||||
|
||||
return array_merge(parent::toArray($request), $personalData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user