mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-28 05:11:39 +08:00
47 lines
955 B
PHP
47 lines
955 B
PHP
<?php
|
|
|
|
namespace App\Services\Logic\Danmu;
|
|
|
|
use App\Models\Danmu as DanmuModel;
|
|
use App\Repos\User as UserRepo;
|
|
use App\Services\Logic\DanmuTrait;
|
|
use App\Services\Logic\Service;
|
|
|
|
class DanmuInfo extends Service
|
|
{
|
|
|
|
use DanmuTrait;
|
|
|
|
public function handle($id)
|
|
{
|
|
$danmu = $this->checkDanmu($id);
|
|
|
|
return $this->handleDanmu($danmu);
|
|
}
|
|
|
|
protected function handleDanmu(DanmuModel $danmu)
|
|
{
|
|
$result = [
|
|
'id' => $danmu->id,
|
|
'text' => $danmu->text,
|
|
'color' => $danmu->color,
|
|
'size' => $danmu->size,
|
|
'position' => $danmu->position,
|
|
'time' => $danmu->time,
|
|
];
|
|
|
|
$userRepo = new UserRepo();
|
|
|
|
$owner = $userRepo->findById($danmu->user_id);
|
|
|
|
$result['owner'] = [
|
|
'id' => $owner->id,
|
|
'name' => $owner->name,
|
|
'avatar' => $owner->avatar,
|
|
];
|
|
|
|
return $result;
|
|
}
|
|
|
|
}
|