Added member and invitation endpoints

This commit is contained in:
Constantin Graf
2024-04-10 17:45:53 +02:00
parent 234fa06324
commit b67961cb07
48 changed files with 1186 additions and 106 deletions

View File

@@ -1,17 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\V1\User;
use Illuminate\Http\Resources\Json\ResourceCollection;
class MemberCollection extends ResourceCollection
{
/**
* The resource that this resource collects.
*
* @var string
*/
public $collects = MemberResource::class;
}

View File

@@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\V1\User;
use App\Http\Resources\V1\BaseResource;
use App\Models\Membership;
use App\Models\User;
use Illuminate\Http\Request;
/**
* @property User $resource
*/
class MemberResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, string|bool|int|null|array<string>>
*/
public function toArray(Request $request): array
{
/** @var Membership $membership */
$membership = $this->resource->getRelationValue('membership');
return [
/** @var string $id ID */
'id' => $this->resource->id,
/** @var string $name Name */
'name' => $this->resource->name,
/** @var string $email Email */
'email' => $this->resource->email,
/** @var string $role Role */
'role' => $membership->role,
/** @var bool $is_placeholder Placeholder user for imports, user might not really exist and does not know about this placeholder membership */
'is_placeholder' => $this->resource->is_placeholder,
/** @var int|null $billable_rate Billable rate in cents per hour */
'billable_rate' => $membership->billable_rate,
];
}
}