Example #1
0
 public function landing(Request $request)
 {
     $landing = Landing::find($request->id);
     $course_id = $landing->course_id;
     $course = Course::find($course_id);
     $courses = Course::all();
     $current_gen = Gen::getCurrentGen();
     $classes = StudyClass::getClassesByCourseAndGen($current_gen->id, $course_id);
     $date_start = $course->classes->sortbyDesc('datestart')->first();
     $bases = Base::all();
     $demos = json_decode($landing->demos, true);
     $timeline = json_decode($landing->timeline, true);
     $feedbacks = json_decode($landing->feedbacks, true);
     $reasons = json_decode($landing->reasons, true);
     $demo_contents = array();
     for ($i = 1; $i <= 6; $i++) {
         if ($demos['demo' . $i]) {
             $product = Product::find($demos['demo' . $i]);
             if ($product->type == 2) {
                 $demo_contents[$i] = $product->content;
             } else {
                 $demo_contents[$i] = '<img src=' . $product->url . '>';
             }
         } else {
             $demo_contents[$i] = '';
         }
     }
     //        dd($demo_contents);
     $this->data['landing'] = $landing;
     $this->data['demo_contents'] = $demo_contents;
     $this->data['demos'] = $demos;
     $this->data['timeline'] = $timeline;
     $this->data['feedbacks'] = $feedbacks;
     $this->data['reasons'] = $reasons;
     $this->data['bases'] = $bases;
     $this->data['date_start'] = $date_start->datestart;
     $this->data['current_gen_id'] = $current_gen->id;
     $this->data['course_id'] = $course_id;
     $this->data['course'] = $course;
     $this->data['classes'] = $classes;
     $this->data['courses'] = $courses;
     return view('public.landing-promo', $this->data);
 }
Example #2
0
 public function landing_delete($id)
 {
     $landing = Landing::find($id);
     $feedbacks = json_decode($landing->feedbacks, true);
     $timeline = json_decode($landing->timeline, true);
     $reasons = json_decode($landing->reasons, true);
     //Handle Reasons Resource Delete
     for ($j = 1; $j <= 3; $j++) {
         deleteFromS3($reasons['reason_img_name' . $j]);
     }
     //Handle Timeline Resource Delete
     $loop = $landing->class_number;
     for ($k = 1; $k <= $loop; $k++) {
         deleteFromS3($timeline['class_img_name' . $k]);
     }
     //Handle Feedback Resource Delete
     for ($j = 1; $j <= 3; $j++) {
         deleteFromS3($feedbacks['feedback_ava_name' . $j]);
     }
     deleteFromS3($landing->cover_promo_name);
     $landing->delete();
     return redirect('/manage/courses');
 }