mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
v5.0.0 update
This commit is contained in:
45
app/Http/Resources/UserResource.php
Normal file
45
app/Http/Resources/UserResource.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\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
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'role' => $this->role,
|
||||
'contact_name' => $this->contact_name,
|
||||
'company_name' => $this->company_name,
|
||||
'website' => $this->website,
|
||||
'enable_portal' => $this->enable_portal,
|
||||
'currency_id' => $this->currency_id,
|
||||
'facebook_id' => $this->facebook_id,
|
||||
'google_id' => $this->google_id,
|
||||
'github_id' => $this->github_id,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'avatar' => $this->avatar,
|
||||
'is_owner' => $this->isOwner(),
|
||||
'roles' => $this->roles,
|
||||
'formatted_created_at' => $this->formattedCreatedAt,
|
||||
'currency' => $this->when($this->currency()->exists(), function () {
|
||||
return new CurrencyResource($this->currency);
|
||||
}),
|
||||
'companies' => $this->when($this->companies()->exists(), function () {
|
||||
return CompanyResource::collection($this->companies);
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user