⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.229
Server IP:
95.217.99.93
Server:
Linux sv1.sonichosted.com 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
Server Software:
LiteSpeed
PHP Version:
8.2.29
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
lifestylescentra
/
public_html
/
app
/
Services
/
View File Name :
EnrollmentService.php
<?php namespace App\Services; use App\Models\WorkoutEnrollment; class EnrollmentService { protected $enrollment; public function __construct(WorkoutEnrollment $enrollment, private WorkoutService $workoutService) { $this->enrollment = $enrollment; } public function all() { return $this->enrollment; } public function enrollWorkout($cart, $user, $extra = []) { $enrollments = []; foreach ($cart as $item) { $workout = $this->workoutService->getWorkout($item["id"]); $data = [ 'workout_id' => $item["id"], 'user_id' => $user->id, 'enroll_date' => now(), 'start_date' => now()->parse($workout->class_start_date)->format('Y-m-d'), 'expire_date' => now()->parse($workout->class_start_date)->addDays($workout->training_days), 'status' => 'active' ]; if ($extra['invoice_id']) { $data['invoice_id'] = $extra['invoice_id']; } if (auth('admin')->user()) { $data['created_by'] = auth('admin')->user()->id; $data['updated_by'] = auth('admin')->user()->id; } $enrollment = $this->enrollment->create($data); array_push($enrollments, $enrollment); } return $enrollments; } }