mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-23 03:50:56 +08:00
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
|
* @license https://opensource.org/licenses/GPL-2.0
|
|
* @link https://www.koogua.com
|
|
*/
|
|
|
|
namespace App\Services\Logic\Course;
|
|
|
|
use App\Builders\ResourceList as ResourceListBuilder;
|
|
use App\Repos\Course as CourseRepo;
|
|
use App\Services\Logic\CourseTrait;
|
|
use App\Services\Logic\Service as LogicService;
|
|
|
|
class ResourceList extends LogicService
|
|
{
|
|
|
|
use CourseTrait;
|
|
|
|
public function handle($id)
|
|
{
|
|
$course = $this->checkCourse($id);
|
|
|
|
$user = $this->getCurrentUser(true);
|
|
|
|
$this->setCourseUser($course, $user);
|
|
|
|
$courseRepo = new CourseRepo();
|
|
|
|
$resources = $courseRepo->findResources($course->id);
|
|
|
|
if ($resources->count() == 0) {
|
|
return [];
|
|
}
|
|
|
|
$builder = new ResourceListBuilder();
|
|
|
|
$relations = $resources->toArray();
|
|
|
|
$uploads = $builder->getUploads($relations);
|
|
|
|
foreach ($uploads as $key => $upload) {
|
|
$uploads[$key]['me'] = ['owned' => $this->ownedCourse ? 1 : 0];
|
|
}
|
|
|
|
return array_values($uploads);
|
|
}
|
|
|
|
}
|