39 lines
839 B
PHP
39 lines
839 B
PHP
|
<?php
|
||
|
|
||
|
namespace Inf;
|
||
|
|
||
|
use Core\Db;
|
||
|
use DateTimeImmutable;
|
||
|
|
||
|
class LastNames
|
||
|
{
|
||
|
private array $lastnames = [];
|
||
|
|
||
|
/** История имён
|
||
|
* @param int $userid
|
||
|
*/
|
||
|
public function __construct(int $userid)
|
||
|
{
|
||
|
$names = Db::getRows('select * from lastnames where uid = ? order by time desc', [$userid]);
|
||
|
$dt = new DateTimeImmutable();
|
||
|
|
||
|
foreach ($names as $name) {
|
||
|
$dt->setTimestamp($name['time']);
|
||
|
$this->lastnames[] = "«{$name['login']}» до " . $dt->format('d.m.Y H:i');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function print(): void
|
||
|
{
|
||
|
echo $this->get();
|
||
|
}
|
||
|
|
||
|
private function get(): string
|
||
|
{
|
||
|
if (empty($this->lastnames)) {
|
||
|
return '';
|
||
|
}
|
||
|
return 'История имен:<br>' . implode('<br>', $this->lastnames);
|
||
|
}
|
||
|
}
|