Files
vintagecoding.net/functions/relationships/spaceMember.php
T
2025-06-10 10:46:22 -06:00

42 lines
946 B
PHP

<?php
class SpaceMember
{
private int $id;
private User $user;
private Space $space;
private int $role;
private DateTime $addedAt;
private bool $favorited;
public function __construct(int $id, User $user, Space $space, int $role, DateTime $addedAt, bool $favorited)
{
error_log('Instantiating a space member');
if (!User::exists($user->getId()) || !Space::exists($space->getId()))
return;
$this->user = $user;
$this->space = $space;
$this->role = $role;
$this->addedAt = $addedAt;
$this->favorited = $favorited;
if ($id < 0) {
$this->id = $id * -1;
$stmt = 'INSERT INTO spaceMembers (id, user, space, role, favorited) VALUES (?, ?, ?, ?, ?)';
exec_stmt($stmt, 'iiiii', $this->id, $user->getId(), $space->getId(), $role, $favorited);
}
}
public function getUser()
{
return $this->user;
}
public function getSpace()
{
return $this->space;
}
}