ActivityController.php
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace App\Http\Container\AppSection\Controllers;
use App\Enums\ActivityAuditStatusEnum;
use App\Helpers\JsonResource;
use App\Mail\ActivityMaterialMail;
use App\Models\Activity;
use App\Models\Views\ActivitySubmitWork;
use App\Support\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class ActivityController extends Controller
{
public function submitAudion(Request $request)
{
$size = $request->get('size', 10);
$activity_id = $request->get('activity_id');
$data = ActivitySubmitWork::query()
->select(['id', 'user_id', 'demo_url', 'durations', 'sing_type', 'mode', 'status', 'activity_id', 'submit_at'])
->with(['user:id,business_id,nick_name,avatar,user_tag_id', 'user.business:id,nick_name,avatar', 'user.userTag:id,name,icon,frame'])
->where(['activity_id' => $activity_id, 'is_hide' => 0])
->withExists('isLike')
->paginate($size);
return JsonResource::success(JsonResource::SUCCESS, ['data' => $data->items(), 'count' => $data->total()]);
}
/**
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\JsonResponse
*/
public function sendMail(Request $request, int $id): JsonResponse
{
$activity = Activity::query()->where('audit_status', ActivityAuditStatusEnum::SUCCESS)->findOrFail($id);
if (empty($request->user()->getAttribute('email'))) {
return JsonResource::fail('请先设置您的邮箱');
}
Mail::send(new ActivityMaterialMail($activity, $request->user()));
return JsonResource::success(JsonResource::SUCCESS);
}
}