@extends('layout.app', ['title' => 'Promotions detail']) @push('style') @vite(['resources/css/layout/banner_main.css', 'resources/css/landing.css']) @vite(['resources/css/promotion.css', 'resources/css/curriculum.css']) @endpush @php use App\Enums\PromotionType; use App\Enums\PromotionStatus; use App\Enums\UserRole; use App\Enums\CourseType; function getPromotion($coursePrice, int $promotionType, $newStudentPromotion): array { if ( Auth::user()->role_id == UserRole::USER->value && $newStudentPromotion && $newStudentPromotion->time == $coursePrice->package_time->time ) { $newUser = true; } else { $newUser = false; } if ($promotionType == PromotionType::DISCOUNT->value) { $disPrice = $coursePrice->price - ($coursePrice->price * $coursePrice->discount) / 100; $data = [ 'title' => $newUser ? 'Tài khoản mới Free các khóa ' . $coursePrice->package_time->time . ' tháng - ' . ($coursePrice->grade ? $coursePrice->grade->name : 'AP') : 'Khuyến mãi ' . $coursePrice->discount . '% các khóa ' . $coursePrice->package_time->time . ' tháng - ' . ($coursePrice->grade ? $coursePrice->grade->name : 'AP'), 'rangeDate' => getFormatDateRange($coursePrice->discount_day_start, $coursePrice->discount_day_end), 'content' => $newUser ? 'Free' : ($coursePrice->grade ? 'Giảm giá ' : 'Discount ') . $coursePrice->discount . '%', 'beforePrice' => number_format($coursePrice->price, 0, '.', '.'), 'afterPrice' => $newUser ? 0 : number_format($disPrice, 0, '.', '.'), 'register' => $coursePrice->discount_status == PromotionStatus::ACTIVE->value ? true : false, 'isAboard' => $coursePrice->grade_id ? false : true, 'start_day' => getFormatDate($coursePrice->discount_day_start), ]; } if ($promotionType == PromotionType::MONTH_GIFT->value) { $disPrice = $coursePrice->price - ($coursePrice->price * $coursePrice->discount) / 100; $data = [ 'title' => 'Tặng thêm ' . $coursePrice->month_gift . ' tháng Các khóa ' . $coursePrice->package_time->time . ' tháng - ' . ($coursePrice->grade ? $coursePrice->grade->name : 'AP'), 'rangeDate' => getFormatDateRange($coursePrice->month_gift_day_start, $coursePrice->month_gift_day_end), 'content' => '+ ' . $coursePrice->month_gift . ($coursePrice->grade ? ' tháng ' : ($coursePrice->month_gift > 1 ? ' months' : ' month')), 'beforePrice' => null, 'afterPrice' => number_format($coursePrice->price, 0, '.', '.'), 'register' => $coursePrice->month_gift_status == PromotionStatus::ACTIVE->value ? true : false, 'isAboard' => $coursePrice->grade_id ? true : false, 'start_day' => getFormatDate($coursePrice->month_gift_day_start), ]; } return $data; } @endphp @section('content')
@include('layout.landing_banner', [ 'title' => 'Chương trình khuyến mãi', 'description' => '', ])
@if (isset($coursePrice->discount_image) || isset($coursePrice->month_gift_image)) Promotion Image @else @endif

{{ getPromotion($coursePrice, $promotionType, $newStudentPromotion)['title'] }}

{{ getPromotion($coursePrice, $promotionType, $newStudentPromotion)['rangeDate'] }}
@foreach ($courses as $course)

{{ $coursePrice->grade_id ? $course->subject->name : 'AP ' . $course->grade->name }}

{{ getPromotion($coursePrice, $promotionType, $newStudentPromotion)['content'] }}
@if (getPromotion($coursePrice, $promotionType, $newStudentPromotion)['beforePrice']) {{ getPromotion($coursePrice, $promotionType, $newStudentPromotion)['beforePrice'] }} Vnd @endif {{ getPromotion($coursePrice, $promotionType, $newStudentPromotion)['afterPrice'] }} Vnd
@if (getPromotion($coursePrice, $promotionType, $newStudentPromotion)['register']) @if (getPromotion($coursePrice, $promotionType, $newStudentPromotion)['isAboard']) {{ $course->type == CourseType::COURSE_SELF_STUDY->value ? 'Đăng ký học' : 'Join the course' }} @else {{ $course->type == CourseType::COURSE_SELF_STUDY->value ? 'Đăng ký học' : 'Join the course' }} @endif @else sắp diễn ra Bắt đầu {{ getPromotion($coursePrice, $promotionType, $newStudentPromotion)['start_day'] }} @endif
@foreach ($course->chapters->sortBy('chapter_number') as $chapter)
@if ($chapter->units) @foreach ($chapter->units->sortBy('unit_number') as $unit)
{{ $course->type == CourseType::COURSE_SELF_STUDY->value ? 'Bài' : 'Topic' }} {{ $unit->unit_number }}: {{ $unit->name }}
@endforeach @endif
@endforeach
@endforeach
@endsection @push('script') @vite('resources/js/curriculum.js') @endpush