From 0b5af7935c836c8aebef000628210c59c5f0fe3f Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Fri, 4 Jul 2025 15:27:57 +0800 Subject: [PATCH] update --- app/Http/Controllers/Admin/CourseContentController.php | 4 ++++ app/Models/CourseContent.php | 10 ++++++++-- .../2025_06_24_111502_alert_course_contents_table.php | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/CourseContentController.php b/app/Http/Controllers/Admin/CourseContentController.php index d422e8a..e7acdf4 100755 --- a/app/Http/Controllers/Admin/CourseContentController.php +++ b/app/Http/Controllers/Admin/CourseContentController.php @@ -147,6 +147,10 @@ class CourseContentController extends BaseController * @OA\Parameter(name="teacher_id", in="query", @OA\Schema(type="integer"), description="老师ID"), * @OA\Parameter(name="address", in="query", @OA\Schema(type="string"), description="地址"), * @OA\Parameter(name="theme", in="query", @OA\Schema(type="string"), description="主题"), + * @OA\Parameter(name="longitude", in="query", @OA\Schema(type="string"), description="经度"), + * @OA\Parameter(name="latitude", in="query", @OA\Schema(type="string"), description="纬度"), + * @OA\Parameter(name="address_detail", in="query", @OA\Schema(type="string"), description="详细地址"), + * @OA\Parameter(name="file_ids", in="query", @OA\Schema(type="string"), description="文件id数组"), * @OA\Response( * response=200, * description="操作成功" diff --git a/app/Models/CourseContent.php b/app/Models/CourseContent.php index 70754c9..622d194 100755 --- a/app/Models/CourseContent.php +++ b/app/Models/CourseContent.php @@ -6,9 +6,15 @@ namespace App\Models; class CourseContent extends SoftDeletesModel { - protected $casts = ['publicize_ids' => 'json']; + protected $casts = ['publicize_ids' => 'json', 'file_ids' => 'json']; - protected $appends = ['publicize']; + protected $appends = ['publicize', 'files']; + + public function getFilesAttribute($value) + { + if (empty($this->file_ids)) return []; + return Upload::whereIn('id', $this->file_ids)->get(); + } public function getPublicizeAttribute($value) { diff --git a/database/migrations/2025_06_24_111502_alert_course_contents_table.php b/database/migrations/2025_06_24_111502_alert_course_contents_table.php index 2f938cd..7bf19fa 100644 --- a/database/migrations/2025_06_24_111502_alert_course_contents_table.php +++ b/database/migrations/2025_06_24_111502_alert_course_contents_table.php @@ -22,6 +22,9 @@ return new class extends Migration $table->dateTime('start_time')->nullable()->comment('开始时间'); // 结束时间 $table->dateTime('end_time')->nullable()->comment('结束时间'); + $table->json('file_ids')->nullable()->comment('文件id数组'); + // 详细地址 + $table->string('address_detail')->nullable()->comment('详细地址'); }); }