101 lines
2.0 KiB
PHP
101 lines
2.0 KiB
PHP
<?php namespace MapGuesser\PersistentData\Model;
|
|
|
|
use DateTime;
|
|
use SokoWeb\PersistentData\Model\Model;
|
|
|
|
class UserPlayedPlace extends Model
|
|
{
|
|
protected static string $table = 'user_played_place';
|
|
|
|
protected static array $fields = ['user_id', 'place_id', 'last_time', 'occurrences'];
|
|
|
|
protected static array $relations = ['user' => User::class, 'place' => Place::class];
|
|
|
|
private ?User $user = null;
|
|
|
|
private ?int $userId = null;
|
|
|
|
private ?Place $place = null;
|
|
|
|
private ?int $placeId = null;
|
|
|
|
private DateTime $lastTime;
|
|
|
|
private int $occurrences = 1;
|
|
|
|
public function setUser(User $user): void
|
|
{
|
|
$this->user = $user;
|
|
}
|
|
|
|
public function setUserId(int $userId): void
|
|
{
|
|
$this->userId = $userId;
|
|
}
|
|
|
|
public function setPlace(Place $place): void
|
|
{
|
|
$this->place = $place;
|
|
}
|
|
|
|
public function setPlaceId(int $placeId): void
|
|
{
|
|
$this->placeId = $placeId;
|
|
}
|
|
|
|
public function setLastTimeDate(DateTime $lastTime): void
|
|
{
|
|
$this->lastTime = $lastTime;
|
|
}
|
|
|
|
public function setLastTime(string $lastTime): void
|
|
{
|
|
$this->lastTime = new DateTime($lastTime);
|
|
}
|
|
|
|
public function setOccurrences(int $occurrences): void
|
|
{
|
|
$this->occurrences = $occurrences;
|
|
}
|
|
|
|
public function incrementOccurrences(): void
|
|
{
|
|
$this->occurrences++;
|
|
}
|
|
|
|
public function getUser(): ?User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function getUserId(): ?int
|
|
{
|
|
return $this->userId;
|
|
}
|
|
|
|
public function getPlace(): ?Place
|
|
{
|
|
return $this->place;
|
|
}
|
|
|
|
public function getPlaceId(): ?int
|
|
{
|
|
return $this->placeId;
|
|
}
|
|
|
|
public function getLastTimeDate(): DateTime
|
|
{
|
|
return $this->lastTime;
|
|
}
|
|
|
|
public function getLastTime(): string
|
|
{
|
|
return $this->lastTime->format('Y-m-d H:i:s');
|
|
}
|
|
|
|
public function getOccurrences(): int
|
|
{
|
|
return $this->occurrences;
|
|
}
|
|
}
|