Exemple #1
0
 public function store(CreateRecordingRequest $request)
 {
     $data = [];
     $data['subject_id'] = $request->input('subject_id');
     $data['semester_id'] = semester()->id;
     $data['student_id'] = student()->id;
     $recording = QuranRecording::firstOrCreate($data);
     $videos = empty($recording->videos) ? [] : unserialize($recording->videos);
     if (!empty($recording->quran_video)) {
         array_push($videos, $recording->quran_video);
     }
     $recording->videos = serialize($videos);
     $recording->fill($request->only('page', 'quran_video'));
     $recording->save();
     $recording->decrement('remaining');
     if ($request->ajax()) {
         return response()->json(true);
     }
     return redirect()->route('students.profile.quran.index');
 }
 public function store(Request $request)
 {
     $filter = ['semester_id' => $this->semester->id, 'student_id' => $this->student->id, 'subject_id' => $request->input('subject_id')];
     $recording = QuranRecording::firstOrCreate($filter);
     $extend = QuranTimeExtend::where($filter)->first();
     if ($extend) {
         $extend->decrement('maximum_recordings');
     }
     $videos = empty($recording->videos) ? [] : unserialize($recording->videos);
     if (!empty($recording->quran_video)) {
         array_push($videos, $recording->quran_video);
     }
     $recording->videos = serialize($videos);
     $recording->quran_video = $request->input('quran_video');
     $recording->page = $request->input('page');
     $recording->save();
     $recording->load('grade');
     $recording->decrement('remaining');
     // $recording->remaining = $recording->remaining - 1;
     $recording->excuse = OrderQuranExcuse::where(['semester_id' => semester()->id, 'student_id' => $recording->student_id, 'subject_id' => $recording->subject_id])->first();
     return response()->json($recording, 200, [], JSON_NUMERIC_CHECK);
 }