public function index() { // dd('asda'); $recordings = QuranRecording::inCurrentSemester()->with('grade', 'student', 'subject', 'evaluator')->paginate(50); // return ($recordings); return view('quran::recordings.index', compact('recordings')); }
/** * Display a listing of the resource. * @return Response */ public function index() { $user = User::findOrFail(user()->id); // dd($user->getPermissions()->find('slug','evaluate_quran.index.quran')); $recordings = QuranRecording::inCurrentSemester()->with('grade', 'subject', 'evaluator')->whereHas('student', function ($query) use($user) { $query->where('gender', $user->sex); })->where('valid', 1)->whereIn('subject_id', $user->quran_subjects->pluck('id')->toArray()); if ($user->canAll(['evaluators.index.quran', 'notes.index.quran'])) { $recordings = QuranRecording::where('valid', 1)->paginate(50); } elseif ($user->canAll('notes.index.quran', 'evaluate_quran.index.quran')) { $recordings = $recordings->where('user_id', '!=', null)->paginate(50); } else { $recordings = $recordings->where('user_id', null)->paginate(50); } // $date = new Date; // to show recording after 5 days // ->where('created_at','<',(Date::Parse($date->format('Y'))->sub('5 Day'))) $videos = !empty($recordings->videos) ? unserialize($recordings->videos) : []; $id = $recordings->pluck('student_id'); return view('quran::quran.index', compact('recordings', 'videos', 'id')); }